2013-10-24 33 views
0

當主TextView(Test123)有2行時,底部的RadioButton不會完全顯示。儘管如此,還是有很多屏幕空間。我猜它與RadioGroup中高度來完成,但是這就是爲什麼我在這裏:)Android佈局不顯示所有內容

<?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="match_parent" 
    android:gravity="center" 
    android:background="@drawable/bkg" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/tOut" 
     android:layout_alignParentRight="true" 
     android:layout_width="wrap_content" 
     android:layout_height="80px" 
     android:textSize="30px" 
     android:textColor="#FFFFFF" 
     android:text="Test123" 
     /> 

    <ImageButton 
     android:layout_below="@id/tOut" 
     android:id="@+id/ranButton" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:src="@drawable/randomize" 
     android:onClick="ranButton" 
     /> 

    <TextView 
     android:layout_below="@id/ranButton" 
     android:id="@+id/between" 
     android:layout_alignParentLeft="true" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:textSize="15dp" 
     android:textColor="#FFFFFF" 
     android:text="Between 0 and:" 
     /> 

    <EditText 
     android:layout_below="@id/between" 
     android:id="@+id/etMax" 
     android:layout_height="40dp" 
     android:layout_width="fill_parent" 
     android:digits="1234567890" 
     android:inputType="numberDecimal" 
     /> 

    <Button 
     android:layout_below="@id/etMax" 
     android:id="@+id/copyButton" 
     android:layout_gravity="bottom" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:textSize="15dp" 
     android:text="Copy Number" 
     android:onClick="copyButton" 
     /> 

    <RadioGroup 
     android:id="@+id/radioGroup" 
     android:layout_below="@id/copyButton" 
     android:layout_height="100px" 
     android:layout_width="fill_parent" 
     android:orientation="horizontal"> 

     <RadioButton 
      android:id="@+id/intRb" 
      android:layout_below="@id/copyButton" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:text="Whole Number" 
      android:checked="true" 
      /> 

     <RadioButton 
      android:id="@+id/decRb" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:text="Decimal" 
      /> 

    </RadioGroup> 

    </RelativeLayout> 
+0

你可以用plz發佈整個xml文件,這樣我就可以粘貼到我的末尾。 – KOTIOS

回答

0

有幾個問題,你的佈局:

  1. 嘗試設置無線電集團高度to wrap_content
  2. 永遠不要使用px來定義視圖的高度...您應該始終使用dp,因爲這將在多個設備上表現最佳
  3. RelativeLayout沒有方向屬性。你應該刪除它。

希望這有助於:)

0

嗨剛剛簽下面的xml文件,我HV編輯的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:layout_margin="10dp" 
    android:gravity="center" 
    > 

    <TextView 
     android:id="@+id/tOut" 
     android:layout_width="wrap_content" 
     android:layout_height="80dp" 
     android:layout_alignParentRight="true" 
     android:text="Test123" 
     android:textColor="#FFFFFF" 
     android:textSize="30dp" /> 

    <ImageButton 
     android:id="@+id/ranButton" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/tOut" 
     android:onClick="ranButton" /> 

    <TextView 
     android:id="@+id/between" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@id/ranButton" 
     android:text="Between 0 and:" 
     android:textColor="#FFFFFF" 
     android:textSize="15dp" /> 

    <EditText 
     android:id="@+id/etMax" 
     android:layout_width="fill_parent" 
     android:layout_height="40dp" 
     android:layout_below="@id/between" 
     android:digits="1234567890" 
     android:inputType="numberDecimal" /> 

    <Button 
     android:id="@+id/copyButton" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/etMax" 
     android:layout_gravity="bottom" 
     android:onClick="copyButton" 
     android:text="Copy Number" 
     android:textSize="15dp" /> 

    <RadioGroup 
     android:id="@+id/radioGroup" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/copyButton" 
     android:layout_marginBottom="5dp" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/intRb" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/copyButton" 
      android:checked="true" 
      android:text="Whole Number" /> 

     <RadioButton 
      android:id="@+id/decRb" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Decimal" /> 
    </RadioGroup> 

</RelativeLayout> 
0

radioGroup中的高度應該是: 機器人:layout_height = 「wrap_content」

intRb不需要

android:layout_below="@id/copyButton" 

如果您使用的是相對佈局,高度應

android:layout_height="wrap_content" 

,並刪除

android:orientation="vertical" 

,如果你想在RadioGroup中是你可以使用 Android的底部: layout_alignParentBottom =「true」 並使用layout_XXXX =「@ id/something」,其中XXXX低於,高於,等等...

否則,你最好使用一個LinearLayout