安卓:滑动抽屉 [英] Android: Sliding Drawer
本文介绍了安卓:滑动抽屉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用我的应用程序(实际上它是一个面板)一个滑动抽屉。我想使该面板滚动。我该怎么做?
下面是XML code表示的部分:
< org.miscwidgets.widget.Panel
机器人:ID =@ + ID / rightPanel3
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:layout_gravity =右
面板:animationDuration =500
面板:closedHandle =@机器人:可绘制/ ic_menu_directions
面板:CONTENT =@ + ID / panelContent
面板:手柄=@ + ID / panelHandle
面板:linearFlying =真
面板:openedHandle =@机器人:可绘制/ ic_menu_directions
面板:位置=右
面板:体重=75%P> <按钮
机器人:ID =@ + ID / panelHandle
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =中心
机器人:layout_marginBottom =20dip/> <的TextView
机器人:ID =@ + ID / panelContent
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:背景=#000000
机器人:重力=左
机器人:填充=4dip
机器人:文字=方向
机器人:文字颜色=#EEE
机器人:TEXTSIZE =16dip
机器人:文字样式=大胆/>
< /org.miscwidgets.widget.Panel>
解决方案
要做些什么,你要找的是简单的。您将要包装一个滚动型内你的TextView @ + ID / panelContent。这将允许开放SlidingDrawer内的内容被滚动。这里是code您正在找什么做的。
< org.miscwidgets.widget.Panel
机器人:ID =@ + ID / rightPanel3
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:layout_gravity =右
面板:animationDuration =500
面板:closedHandle =@机器人:可绘制/ ic_menu_directions
面板:CONTENT =@ + ID / panelContent
面板:手柄=@ + ID / panelHandle
面板:linearFlying =真
面板:openedHandle =@机器人:可绘制/ ic_menu_directions
面板:位置=右
面板:体重=75%P> <按钮
机器人:ID =@ + ID / panelHandle
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =中心
机器人:layout_marginBottom =20dip/> <滚动型
机器人:ID =@ + ID / panelContent
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
andrid:fillViewport =真正的>
<的TextView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:背景=#000000
机器人:重力=左
机器人:填充=4dip
机器人:文字=方向
机器人:文字颜色=#EEE
机器人:TEXTSIZE =16dip
机器人:文字样式=大胆/>
< /滚动型>
< /org.miscwidgets.widget.Panel>
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>
解决方案
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>
这篇关于安卓:滑动抽屉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文