Scrollable list of buttons within SliderDrawer
No luck after a few days of researching this one. Should be simple, but I'm just not seeing it.
There is an activity page, which has a SliderDrawer. SlidingDrawer icon sits at the bottom, on click or swipe slides open drawer correctly with list of buttons. That all works fine. The problem I'm having is that to accomodate different screensizes and orientations, and the likely addition of additional buttons, I need the contents of that SlidingDrawer to be scrollable. Layout is below. I have tried wrapping the LinearLayout that holds the buttons in a ScrollView without success.
Suggestions?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/fron开发者_开发百科tpagetitlewrapper"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="blah"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:gravity="center"
android:layout_alignParentTop="true"
/>
<TextView
android:id="@+id/mid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="and"
android:textColor="#000000"
android:layout_below="@+id/top"
android:textSize="16sp"
android:textStyle="bold"
android:gravity="center"
/>
<TextView
android:id="@+id/bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="blather"
android:textColor="#000000"
android:layout_below="@+id/mid"
android:textSize="18sp"
android:textStyle="bold"
android:gravity="center"
/>
</LinearLayout>
<FrameLayout
android:layout_width="fill_parent"
android:id="@+id/frameLayout"
android:layout_alignParentBottom="true">
<SlidingDrawer android:layout_height="wrap_content"
android:handle="@+id/handle"
android:content="@+id/content"
android:id="@+id/slide"
android:orientation="vertical"
android:layout_width="fill_parent"
>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@id/handle"
android:src="@drawable/opendrawer">
</ImageView>
<ScrollView
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@id/content"
android:orientation="vertical">
<Button android:text="a" android:id="@+id/btnA" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="20dip"></Button>
<Button android:text="b" android:id="@+id/btnB" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="20dip"></Button>
<Button android:text="c" android:id="@+id/btnC" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="20dip"></Button>
<Button android:text="d" android:id="@+id/btnD" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="20dip"></Button>
<Button android:text="e" android:id="@+id/btnE" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="20dip"></Button>
<Button android:text="f" android:id="@+id/btnF" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="20dip"></Button>
</LinearLayout>
</ScrollView>
</SlidingDrawer>
</FrameLayout>
</RelativeLayout>
I think your problem is that you've tagged the nested LinearLayout with instruction
android:id="@id/content"
so that's the component the SlidingDrawer is using for the content. Try tagging the ScrollView instead.
<?xml version="1.0" encoding="utf-8"?>
<SlidingDrawer android:layout_width="wrap_content"
android:id="@+id/SlidingDrawer" android:handle="@+id/slideHandleButton"
android:content="@+id/contentLayout" android:padding="10dip"
android:layout_height="250dip">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/slideHandleButton"
android:background="@drawable/closearrow"></Button>
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/contentLayout" android:orientation="vertical"
android:gravity="center|top" android:padding="10dip"
android:background="#C0C0C0" android:layout_height="wrap_content">
<Button android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Content"></Button>
<Button android:id="@+id/Button02" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Content"></Button>
<Button android:id="@+id/Button03" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Content"></Button>
</LinearLayout>
</SlidingDrawer>
精彩评论