开发者

Artefacts in list on Gingerbread when using fragment library

I am porting my settings screen to Honeycomb, but since it should still be available on Gingerbread I am using the fragment support library. Phone testing on a Nexus One.

When running this on a Gingerbread tablet everything looks just fine. When running it on the phone the top of the pixels are missing, and the text is gone. If I try to scroll the list (it contains four elements, so it doesn't move at all) the text appears. However, the moment I click on an item the text disappears again.

My fragment looks like this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <fragment class="dk.nindroid.rss.settings.SourceSelector"
            android:id="@+id/sources"
            android:layout_width="match_parent" android:layout_height="match_parent" />
</FrameLayout>

And the list like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <ImageView android:id="@+id/icon" 
        android:layout_width="48dip"
        android:layout_height="48dip"
        android:layout_alignParentLeft="true" />
    <TextView android:id="@id/android:title" 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:gravity="center_vertical"
        android:textSize="24sp"
        android:textColor="#FFFFFF"
        android:paddingLeft="10sp"
        android:sin开发者_StackOverflow社区gleLine="true" />
</LinearLayout>

Without, the screen looks like this. With text, the top of the text is also cut off.

Artefacts in list on Gingerbread when using fragment library

Edit: I should probably add a question: Am I doing something wrong, or is this an error in the fragments support library?


The problem was the line in the FragmentActivity (that I did not post):

getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

Removing this (or rather only showing it on Honeycomb+ devices fixed the problem:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜