2013-09-27 87 views
0

最后两个按钮,我在新的Android。我希望页面的顶部有一个ImageView,页面底部有4个按钮,页面中间有一个frameLayout。我已经完成了一个用于在FrameLayout中加载的xml文件。它包含ScrollView和10个按钮。但是当我运行该程序时,最后两个按钮在滚动页面后不会显示在页面上。不显示了滚动型

任何人可以帮助我吗?

的main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="@drawable/background"> 

    <ImageView 
     android:id="@+id/yellowbar" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/smallyelowbar" 
     android:adjustViewBounds="true" 
     android:scaleType="fitXY" 
     android:layout_alignParentTop="true"/> 
<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="0" 
    android:layout_gravity="bottom" 
    android:layout_below="@id/yellowbar"> 
     <FrameLayout 
      android:id="@+id/frameLayout" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1"/> 

</RelativeLayout> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_alignParentBottom="true"> 
     <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/topmenu" 
      android:adjustViewBounds="true" 
      android:scaleType="fitXY"/> 
       <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_alignParentBottom="true"> 

     <Button android:id="@+id/btn1" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/more_selector"/> 
     <Button 
      android:id="@+id/btn2" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/contact_selector"/> 
     <Button android:id="@+id/btn3" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/product_selector"/> 
     <Button android:id="@+id/btn4" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/introduce_selector"/> 
     </LinearLayout> 
     </LinearLayout> 
</RelativeLayout> 

scrooll.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical"> 

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<Button 
    android:id="@+id/btn1_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:text="@string/btn1_product" 
    android:textColor="@color/white" 
    android:textSize="10sp"/> 
<Button 
    android:id="@+id/btn2_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn2_product" 
    android:layout_below="@id/btn1_product" 
    android:textSize="10sp"/> 
<Button 
    android:id="@+id/btn3_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn3_product" 
    android:layout_below="@id/btn2_product" 
    android:textSize="10sp"/> 
<Button 
    android:id="@+id/btn4_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn4_product" 
    android:layout_below="@id/btn3_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn5_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn5_product" 
    android:layout_below="@id/btn4_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn6_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn6_product" 
    android:layout_below="@id/btn5_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn7_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn7_product" 
    android:layout_below="@id/btn6_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn8_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn8_product" 
    android:layout_below="@id/btn7_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn9_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn9_product" 
    android:layout_below="@id/btn8_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn10_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn10_product" 
    android:layout_below="@id/btn9_product" 
    android:textSize="12sp"/> 

</RelativeLayout> 
</ScrollView> 

</LinearLayout> 

感谢您的帮助。

+0

我不知道,但我想的LinearLayout应该是滚动型的内部。 ScrollView中的RelativeLayout不应该是必需的。 – Day

+0

'RelativeLayout'是必需的,@Day。 'ScrollView'只能容纳一个元素。 –

+0

感谢快速reply.I删除的LinearLayout但不显示最后两个按钮。我想如果我将RelativeLaout更改为LinearLayout,则不能解决问题。我认为最后两个按钮隐藏了页面底部的按钮。 – SensorS

回答

0

尝试给 “WRAP_CONTENT” 身高

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > </ScrollView> 
+0

我改变高度滚动型由没有解决:(我该如何解决这个问题?谢谢 – SensorS

+0

我认为这个问题是对的LinearLayout main.xml中程序WRAP_CONTENT。但我不知道我怎样才能改变这一点,直到问题解决:( – SensorS

+0

我看到main.xml中的预览页面,我看到的FrameLayout低于ImageView的,直到页面底部和按钮时的FrameLayout的。我觉得,我应该在的ImageView和按键之间的页面中设置的FrameLayout,请告诉我怎样才能实现这个??? – SensorS

0

在第一个XML的最后LinearLayout添加android:weightSum=4

+0

我添加这个去年的LinearLayout,但问题没有解决:( – SensorS

+0

转换的RelativeLayout到的LinearLayout,它会工作。 – Swetank

0

转换的RelativeLayout到的LinearLayout,它会工作。