Im tryng to use SlidingDrawer on android.
When you click on ImageButton "handle", SlidingDrawer "slidingDrawerMP" should overlap "coversSongLayout" Linear Layout, but it don't work. Any suggestions?
Thank you
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="top"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:id="@+id/coversSongLayout"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_weight="1">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/coversLayout" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:columnWidth="90dp"
android:numColumns="auto_fit" andro开发者_如何转开发id:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:stretchMode="columnWidth"
android:gravity="center" android:layout_weight="1" />
</LinearLayout>
<FrameLayout android:id="@+id/linearLayoutMP"
android:layout_height="28dp" android:gravity="bottom"
android:layout_width="fill_parent" android:background="@android:color/transparent"
android:layout_margin="0dip">
<SlidingDrawer android:id="@+id/slidingDrawerMP"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:handle="@+id/handle" android:content="@+id/content"
android:background="#aa0000">
<ImageButton android:id="@+id/handle"
android:layout_width="wrap_content" android:src="@drawable/up"
android:background="#fff" android:layout_height="wrap_content"></ImageButton>
<LinearLayout android:id="@+id/content"
android:background="#ccaaaaaa" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout android:gravity="center"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:id="@+id/currentSongLayout">
<LinearLayout android:id="@+id/coverLayout"
android:orientation="horizontal" android:gravity="center"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<ImageView android:id="@+id/cover" android:src="@drawable/generic_cover"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/songLayout"
android:orientation="horizontal" android:gravity="center"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Unknowed Song" />
</LinearLayout>
<LinearLayout android:id="@+id/artistAlbumLayout"
android:orientation="horizontal" android:gravity="center"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Unknowed Artist" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=" - " />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Unknowed Album" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</SlidingDrawer>
</FrameLayout>
<LinearLayout android:id="@+id/mediaControls"
android:orientation="horizontal" android:background="#ccaaaaaa"
android:layout_width="match_parent" android:layout_height="53dp">
<ImageButton android:layout_height="wrap_content"
android:background="@null" android:layout_width="fill_parent"
android:layout_weight="1" android:src="@drawable/prev" android:id="@+id/prev"></ImageButton>
<ImageButton android:layout_height="wrap_content"
android:background="@null" android:layout_width="fill_parent"
android:layout_weight="1" android:src="@drawable/play" android:id="@+id/play" />
<ImageButton android:layout_height="wrap_content"
android:background="@null" android:layout_width="fill_parent"
android:layout_weight="1" android:src="@drawable/next" android:id="@+id/next" />
</LinearLayout>
</LinearLayout>
The FrameLayout containing the sliding drawer is only 28 dp high, it needs to be as big as the opened size of the drawer. Usually you want the drawer's container to be as big as the screen.
I had problems with sliding drawer in linear layout as well. It seems the root layout of yours should be a frame or a relative layout for the sliding drawer to be on top of the rest of your content. (seems logical as well). Also check for the height as Romain sugested.
精彩评论