2012-06-24 1 views
12

次のコードでは、ラジオボタンの外観は、私は私が_radioについて話しています違いlayout_width

android:layout_width="fill_parent" 

android:width="fill_parent" 

を設定変更するとき、なぜボタン_そのIDがleft

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

<RadioGroup 
    android:id="@+id/orientation" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:padding="5px" > 

    <RadioButton 
     android:id="@+id/horizontal" 
     android:text="horizontal" /> 

    <RadioButton 
     android:id="@+id/vertical" 
     android:text="vertical" /> 
</RadioGroup> 

<RadioGroup 
    android:id="@+id/gravity" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:padding="5px" 

    > 

    <RadioButton 
     android:id="@+id/left" 
     android:text="left" 
     android:layout_width="fill_parent" // I am talking about this line 
     /> 

    <RadioButton 
     android:id="@+id/center" 
     android:text="center" /> 

    <RadioButton 
     android:id="@+id/right" 
     android:text="right" /> 
</RadioGroup> 

+0

重複:[Duplicate](http://stackoverflow.com/questions/2713795/what-is-the-difference-between-androidlayout-width-and-androidwidth) – adneal

答えて

14

android:width正確なピクセル数を設定します。

android:layout_widthは、上記のような次元でもよく、fill_parent,match_parentまたはwrap_contentのいずれかです。

android:widthのディメンション以外を使用するとエラーが発生します。

+0

私は 'android:width'を削除すると外観が変わって、効果があります – HforHisham

+0

@HeshamAbouelsoaod申し訳ありませんが、私は 'RadioButton'が実際には' TextView'のサブクラスであるとは思いませんでした。私は私の答えを更新しました。 –

+0

okありがとう...... – HforHisham

関連する問題