问题
I am using a sliding drawer on my application (actually its a Panel). I would like to make that panel scrollable. How can I do that?
Here is the xml code for that part:
<org.miscwidgets.widget.Panel
android:id="@+id/rightPanel3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="right"
panel:animationDuration="500"
panel:closedHandle="@android:drawable/ic_menu_directions"
panel:content="@+id/panelContent"
panel:handle="@+id/panelHandle"
panel:linearFlying="true"
panel:openedHandle="@android:drawable/ic_menu_directions"
panel:position="right"
panel:weight="75%p" >
<Button
android:id="@+id/panelHandle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="20dip" />
<TextView
android:id="@+id/panelContent"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#000000"
android:gravity="left"
android:padding="4dip"
android:text="Directions"
android:textColor="#eee"
android:textSize="16dip"
android:textStyle="bold" />
</org.miscwidgets.widget.Panel>
回答1:
To do what you are looking for is simple. You will want to wrap your TextView @+id/panelContent inside of a ScrollView. This will allow the content inside the open SlidingDrawer to be scrolled. Here is the code for what you are looking to do.
<org.miscwidgets.widget.Panel
android:id="@+id/rightPanel3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="right"
panel:animationDuration="500"
panel:closedHandle="@android:drawable/ic_menu_directions"
panel:content="@+id/panelContent"
panel:handle="@+id/panelHandle"
panel:linearFlying="true"
panel:openedHandle="@android:drawable/ic_menu_directions"
panel:position="right"
panel:weight="75%p" >
<Button
android:id="@+id/panelHandle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="20dip" />
<ScrollView
android:id="@+id/panelContent"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
andrid:fillViewport="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#000000"
android:gravity="left"
android:padding="4dip"
android:text="Directions"
android:textColor="#eee"
android:textSize="16dip"
android:textStyle="bold" />
</ScrollView>
</org.miscwidgets.widget.Panel>
来源:https://stackoverflow.com/questions/10017008/android-sliding-drawer