Reputation: 7519
I am using w2davids calendar and in that calendar, the author of the code has used an image (ImageView) to display the weekdays:
<LinearLayout
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/calendarheader"
android:src="@drawable/blue_bg_with_text"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
I would not like to use an image for the weekdays. How can I set it programmatically?
Upvotes: 0
Views: 322
Reputation: 67502
Create a horizontal LinearLayout
with seven TextView
s. You can set their contents using DateUtils.getDayOfWeekString()
. (I'm not sure if that DateUtils
method is locale-compliant; if it's not, try this method.)
In terms of formatting, using a center gravity
on each TextView
and a large upper padding on the LinearLayout
should work fine, and you can set the background to whatever you need using a drawable.
Upvotes: 3