我正在开发一个非常基本的应用程序,我需要在页面上有大量的按钮。一个点后只有一个有限的没有按钮的问题显示在页面上..其余的要么是在页面或迷失方向。我想做的就是假设有50个按钮,那么我希望在一个页面上显示25个按钮,在另一个页面上显示25个按钮。 如果这是不可能的,那么至少按钮不会丢失,我可以使用滚动按钮或其他东西访问它们。
我试过<Scrollview>
,但没有任何帮助。
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center" >
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="FUNNY SOUNDS"
android:layout_gravity="center"
android:layout_marginLeft="55sp"
android:id="@+id/tv"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="8" >
<Button
android:id="@+id/b1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="History"
android:layout_weight="2"
android:background="@drawable/custom" />
<Button
android:id="@+id/b2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="History"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="History"
android:layout_weight="2"
android:background="@drawable/custom" />
<Button
android:id="@+id/b4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Go"
android:layout_weight="2"
android:background="@drawable/custom"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="8"
>
<Button
android:id="@+id/b5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Refresh"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="History"
android:layout_weight="2"
android:background="@drawable/custom"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="8" >
<Button
android:id="@+id/b9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back"
android:layout_weight="2"
android:background="@drawable/custom" />
<Button
android:id="@+id/b10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Refresh"
android:layout_weight="2"
android:background="@drawable/custom"
/>
<Button
android:id="@+id/b12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="History"
android:layout_weight="2"
android:background="@drawable/custom" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="8" >
<Button
android:id="@+id/b13"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b14"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b15"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Refresh"
android:layout_weight="2"
android:background="@drawable/custom"/>
<Button
android:id="@+id/b16"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="History"
android:layout_weight="2"
android:background="@drawable/custom" />
</LinearLayout>
</LinearLayout>
如果有任何进一步的解释,我会很抱歉。如果有任何建议,谢谢。我该如何处理这个问题。应该采取什么方法。
答案 0 :(得分:0)
在每个ScrollView
之前尝试使用LinearLayout
。
请记住,ScrollView只能应用于一个视图/布局。
因此您需要为所有布局编写它。
<LinearLayout
....>
<ScrollView
...>
<LinearLayout
....>
<Button
android:id="@+id/b1"
..../>
<Button
android:id="@+id/b2"
..../>
<Button
android:id="@+id/b3"
..../>
</LinearLayout>
</ScrollView>
</LinearLayout>
希望它适合你。