如何在android中为多个按钮设置可滚动按钮?
我有5个按钮,我想滚动所有按钮,我的代码是如何在android中为多个按钮设置可滚动按钮?,android,scrollable,Android,Scrollable,我有5个按钮,我想滚动所有按钮,我的代码是 您只需将所有按钮保留在一个布局(相对布局)中,并将此布局保留在scrollview中。现在布局中的所有按钮都将滚动 <RelativeLayout> <ScrollView> <RelativeLayout> <Button> //Place code for button1 </Button> <Button> //
您只需将所有按钮保留在一个布局(相对布局)中,并将此布局保留在scrollview中。现在布局中的所有按钮都将滚动
<RelativeLayout>
<ScrollView>
<RelativeLayout>
<Button>
//Place code for button1
</Button>
<Button>
//Place code for button2
</Button>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
//按钮1的位置代码
//按钮2的位置代码
该代码无法正常工作。它应该是
而不是
<RelativeLayout>
<ScrollView>
<RelativeLayout>
<Button>
//Place code for button1
</Button>
<Button>
//Place code for button2
</Button>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:id="@+id/linearLayout1"
android:orientation="horizontal"
android:layout_height="fill_parent">
<Button
android:id="@+id/btnAll"
android:layout_height="wrap_content"
android:layout_width="80dip"
android:text="All"
android:background="@drawable/icon" />
<Button
android:id="@+id/btnBarAndRes"
android:layout_height="wrap_content"
android:layout_width="80dip"
android:text="Bar Restaurants"
android:layout_toRightOf="@+id/btnAll"
android:background="@drawable/icon" />
<Button
android:id="@+id/btnFashion"
android:layout_height="wrap_content"
android:layout_width="80dip"
android:text="FashionBeauty"
android:layout_toRightOf="@+id/btnBarAndRes"
android:background="@drawable/icon"/>
<Button
android:id="@+id/btnParty"
android:layout_height="wrap_content"
android:layout_width="80dip"
android:text="PartyEntertainment"
android:layout_toRightOf="@+id/btnFashion"
android:background="@drawable/icon"
/>
<Button
android:id="@+id/btnLife"
android:layout_height="wrap_content"
android:layout_width="80dip"
android:text="Life Style"
android:layout_toRightOf="@+id/btnParty"
android:background="@drawable/icon"
/>
</LinearLayout>
</HorizontalScrollView>
</ScrollView>