0

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>

enter image description here

I would not like to use an image for the weekdays. How can I set it programmatically?

input
  • 7,503
  • 25
  • 93
  • 150

1 Answers1

3

Create a horizontal LinearLayout with seven TextViews. 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.

Community
  • 1
  • 1
Cat
  • 66,919
  • 24
  • 133
  • 141
  • Eric, DateUtils support localization! I've just get it display in Japanese correctly 日月火水木金土. – yancyn Apr 22 '13 at 09:09