Sliding drawer has 1 transparent pixel between handlebar & content pane
I have created a sliding drawer with a handle bar and a content pane. There seems to be a single transparent pixel between the handle bar and the content pane. how can i get rid of this. here is my layout xml:
<?xml version="1.0" encoding="utf-8"?>
<SlidingDrawer android:id="@+id/drawer" visible="visible"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:handle="@+id/handle" android:content="@+id/content"
android:orientation="vertical">
<RelativeLayout android:id="@id/handle"
android:background="@drawable/slider_gradient" android:layout_width="fill_parent"
android:orientation="horizontal" android:layout_height="44dip">
<ImageView android:id="@+id/slider_icon"
android:layout_width="44dip" android:layout_height="44dip"
android:layout_gravity="left" android:layout_alignParentLeft="true"
android:src="@drawable/icon">
</ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/selected_list_view"
android:textColor="@android:color/black" android:layout_toRightOf="@id/slider_icon"
android:text="" android:textSize="18dip" android:layout_alignBottom="@id/slider_icon" />
</RelativeLayout>
<FrameLayout android:id="@id/content" android:background="@drawable/pulse_sub_row_gradient"
android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="wrap_content">
<GridView android:id="@+id/button_grid" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:numColumns="auto_fit"
android:stretchMode="columnWidth" android:gravity="cent开发者_StackOverflower">
</GridView>
</FrameLayout>
</SlidingDrawer>
Try to add drawable folders for the slider icon so that the platform can correctly scale your image depending on the density of the current screen.
res/drawable-ldpi/slider_icon.png // icon image for low density res/drawable-mdpi/slider_icon.png // icon for medium density res/drawable-hdpi/slider_icon.png // icon image for high density
From the code above, I can see you're adding the sliding image resource to default drawable resource without actually paying attention to the screen density size, this may not work as expected as the platform is just loading your image as the default medium size density. This may look correct in the emulator but will produce the effect you describe above when running in a real device.
I just wasted a day trying to figure this out. Turned out the default scaling setting in ImageView for the handle was wrong (for me). Try android:scaleType="center". I'm not sure what the default is, and the gap for me was a lot bigger than 1 pixel but it worked great when I added it. Good luck!
精彩评论