在滑动抽屉中添加滚动视图

时间:2011-08-30 12:48:13

标签: android scrollbar slidingdrawer

我在我的应用程序中使用了SlidingDrawer。现在我想在其中添加滚动视图。我试过这样做,但它给了我一个错误,说滑动抽屉必须有指定的尺寸 任何人都可以帮助我。

2 个答案:

答案 0 :(得分:1)

对于 scrollview ,您必须至少键入:

<ScrollView
    android:layout_width="fill_parent or wrap_content or your value" 
    android:layout_height="fill_parent or wrap_content or your value" >
</ScrollView>

答案 1 :(得分:1)

您需要设置layout_width和layout_height,因为Yann MASOCH表示要删除该错误消息。

另外请记住在scrollview中将id设置为id / content而不是linearLayout,以便slidedrawer能够使用scroll。以下是带滚动的SlidingDrawer示例:

<SlidingDrawer
 android:id="@+id/drawer"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:handle="@+id/handle"
 android:content="@+id/content">

 <Button
     android:id="@id/handle"
     android:layout_width="88dip"
     android:layout_height="44dip"
     android:background="@drawable/btn_blue"
     android:text="help"
     android:textColor="#ffffff"/>
 <ScrollView
  android:id="@id/content"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">

<LinearLayout
    android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent">

(other TextViews etc)

</LinearLayout>
</ScrollView>
</SlidingDrawer>
相关问题