2013-09-27 25 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,它會工作。