I have a custom view , I have put some TextView inside that and i have to change the layout property of each child view differently. I won't able to change textview property by xml,
Here is my xml:
<com.squareup.timessquare.CalendarRowView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/calendar_day_headers_paddingbottom">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CalendarCell.DayHeader"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CalendarCell.DayHeader"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CalendarCell.DayHeader"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CalendarCell.DayHeader"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CalendarCell.DayHeader"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CalendarCell.DayHeader"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CalendarCell.DayHeader"
/>
</com.squareup.timessquare.CalendarRowView>
Above is xml file in which there is 8 textview is defined I want each textview have different width,
and following is the java code for that...
public static MonthView create(ViewGroup parent, LayoutInflater inflater,
DateFormat weekdayNameFormat, Listener listener, Calendar today)
{
final MonthView view = (MonthView) inflater.inflate(R.layout.month, parent, false);
final int originalDayOfWeek = today.get(Calendar.DAY_OF_WEEK);
int firstDayOfWeek = today.getFirstDayOfWeek();
final CalendarRowView headerRow = (CalendarRowView) view.grid.getChildAt(0);
for (int offset = 0; offset < 7; offset++)
{
today.set(Calendar.DAY_OF_WEEK, firstDayOfWeek + offset);
final TextView **textView** = (TextView) headerRow.getChildAt(offset);
textView.setText(weekdayNameFormat.format(today.getTime()));
}
today.set(Calendar.DAY_OF_WEEK, originalDayOfWeek);
view.listener = listener;
return view;
}