Wednesday, 11 September 2013

Strange XML layout bug when targeting Android 4.3

Strange XML layout bug when targeting Android 4.3

I'm experiencing a really peculiar bug with an XML layout file when
building my application while targeting API level 18. It doesn't happen
with API level 17.
Here's what it looks like:
API 17 (correct):

API 18 (incorrect):

I'm using the StickyGridHeaders library, and the following is my
getHeaderView() method:
@Override
public View getHeaderView(int position, View convertView, ViewGroup parent) {
RowItem holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.seasons_row_header,
parent, false);
holder = new RowItem();
holder.title = (TextView) convertView.findViewById(R.id.seasonTitle);
holder.episodeCount = (TextView)
convertView.findViewById(R.id.episodeCount);
convertView.setTag(holder);
} else {
holder = (RowItem) convertView.getTag();
}
if (seasons.get(position).equals("00")) {
holder.title.setText(R.string.stringSpecials);
} else {
holder.title.setText(getString(R.string.showSeason) + " " +
seasons.get(position));
}
int size =
seasonEpisodeCount.get(Integer.valueOf(seasons.get(position)));
holder.episodeCount.setText(size + " " +
getResources().getQuantityString(R.plurals.episodes, size, size));
convertView.setClickable(false);
convertView.setFocusable(false);
return convertView;
}
Here's the layout XML file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#80000000"
android:padding="@dimen/list_padding" >
<TextView
android:id="@+id/seasonTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="@dimen/list_padding"
android:layout_toLeftOf="@+id/episodeCount"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false"
android:textStyle="bold" />
<TextView
android:id="@+id/episodeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/seasonTitle"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/seasonTitle"
android:gravity="bottom"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false" />
</RelativeLayout>
Does anyone else have a clue as to what's going on here? I find it really
strange that it's working when targeting API level 17 and not working when
targeting the latest API level (18).

No comments:

Post a Comment