I have a listbox with a custom background. It displays a thin white line on either side with a black background. Works great on all my test phones (Galaxy Captivate, Vibrant, Nexus 1, G Tablet, Archos 32, Droid). I just got a Droid 3 to test on, and on this one phone, the background of the listview where there are no items is grey. The list items have the correct black background.
Here's the layout containing the list view. The listview has white background text box above and below, and the background for the listview is the drawable (I know it's called a three border, but it's only a two border).
<RelativeLayout
android:layout_below="@id/divider01"
android:layout_above="@id/save_current_button"
android:id="@+id/profile_middle_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="3dip"
android:orientation="vertical">
<TextView android:id="@+id/user_profile_row"
android:text="@string/user_profiles_label"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/black"
android:background="@drawable/roundedtop"/>
<TextView android:id="@+id/current_profile_name"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#2B497B"
android:background="@drawable/roundedbottom"/>
<ListView android:id="@id/android:list"
android:layout_below="@id/user_profile_row"
android:layout_above="@id/current_profile_name"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="3dip"
android:paddingRight="3dip"
android:drawSelectorOnTop开发者_开发百科="false"
android:background="@drawable/three_side_border"
android:cacheColorHint="#ffffffff"/>
</RelativeLayout>
Here's the drawable - this should force the background to black.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="#FFFFFFFF" />
</shape>
</item>
<item android:left="3dp" android:right="3dp">
<shape android:shape="rectangle">
<solid android:color="#FF000000" />
</shape>
</item>
</layer-list>
I noticed that in my list item xml, I don't have the alpha layer specified in my colors, so I tried taking off the leading FF on my drawable, but it came out the same.
Anyone have any ideas where I can look to fix this? It looks really ugly on a nice phone.
Thanks, Greg
A buddy found a comment on a Motorola forum:
Motorola changed attribute values for built-in themes on Moto devices with 2.3. "If you set
overScrollFooter
to@null
, the bottom-of-list background becomes transparent and your background image shows through.... If you want a bottom-of-list background, but a different one, you can setoverScrollFooter
to a color or drawable..."
android:overScrollFooter="#aa000000"
android:overScrollFooter="@drawable/my_drawable"
http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/ba-p/17462
I'm still not entirely sure what they are doing when rendering this space, but I can get it to work. If I use the drawable option, and give it my drawable with the left and right borders, that object gets drawn inside the border from the listview background - i.e. it is somehow still showing the first item in my two-layer background drawable, so the space below my list items now has a wider border, but it is black. This is at least consistent with my earlier test when I changed the first layer to blue, and got a blue line the entire height of the listview. If I just go with a straight black #ff000000
, then the listview looks the same as all my other phones. So I'm not sure how they are calculating the footer space - I don't see how they would know that I have a two-layer object and just be replacing the second layer. Something else must be going on that I just don't understand, but it does work.
There was a also a comment that you would need to select a theme based on the android version, but so far in my testing all the platforms take the new tag without complaining.
精彩评论