2013-05-30 58 views
0

我正在开发一个非常基本的应用程序,我需要在页面上有大量的按钮。点后面的问题只有有限的按钮没有显示一页......其余的页面不在页面或者迷失方向。我想要做的就像是假设有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> 

对不起,我的英文不好,如果任何进一步解释我will.Thank的。如何,我应该与problem.What进行应该是方法的任何建议。

+1

为什么'ScrollView'没有帮助?你有什么尝试过吗? – Laksh

+0

我试过'Scrollview',能够得到滚动条,但没有显示丢失的按钮 – user2373603

回答

0

在每个LinearLayout之前尝试使用ScrollView

记住一个ScrollView只能应用于一个视图/布局。

因此,您需要为所有布局编写它。

<LinearLayout 
    ....> 
    <ScrollView 
     ...> 
     <LinearLayout 
      ....> 
      <Button 
       android:id="@+id/b1" 
       ..../> 
      <Button 
       android:id="@+id/b2" 
       ..../> 
      <Button 
       android:id="@+id/b3" 
       ..../> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

希望它适合你。