在抽屉里面装上seekBar

时间:2014-09-19 11:28:19

标签: android xml drawerlayout android-seekbar

我如何使搜索栏适合留在抽屉边界内?

这是我的drawerLayout

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:background="#111"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

    <LinearLayout
        android:id="@+id/right_drawer_ll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:orientation="vertical"
        android:visibility="visible" >

        <SeekBar
            android:id="@+id/seekBar1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <ListView
            android:id="@+id/right_drawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:background="#123456"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp" />
    </LinearLayout>

</android.support.v4.widget.DrawerLayout>

使用此代码,seekBar显示在drawerLayout内,而不是在rightDrawer边界内。

立即更新 enter image description here

我想要

enter image description here 是否有可能实现这一目标?

提前感谢。

1 个答案:

答案 0 :(得分:1)

你没有framelayout。所以,你的linearlayout代替了它。

修改你的布局如下

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </FrameLayout>

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#111"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

    <LinearLayout
        android:id="@+id/right_drawer_ll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:background="@android:color/white"
        android:orientation="vertical"
        android:visibility="visible" >

        <SeekBar
            android:id="@+id/seekBar1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="14dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="10dp"
            android:max="5"
            android:progress="0" />

        <ListView
            android:id="@+id/right_drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:background="#123456"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp" />
    </LinearLayout>

</android.support.v4.widget.DrawerLayout>

enter image description here