私のアプリのレイアウトは480dpi、480/4は120です。アプリの上部に4つのボタンがあり、120dpiの幅に設定すると、なぜボタンが半分かかりますスクリーン?!一番上に均等にサイズを設定するにはどうすればよいですか?アクティビティの要素の幅が正しくありませんか?
ここ、私はちょうど上部にある4つのボタンを追加した:
そして最初の二つのボタンは、DPI 120の幅である:
あなたがレイアウトのFILL_PARENTパラメータを使用することができ私のアプリのレイアウトは480dpi、480/4は120です。アプリの上部に4つのボタンがあり、120dpiの幅に設定すると、なぜボタンが半分かかりますスクリーン?!一番上に均等にサイズを設定するにはどうすればよいですか?アクティビティの要素の幅が正しくありませんか?
ここ、私はちょうど上部にある4つのボタンを追加した:
そして最初の二つのボタンは、DPI 120の幅である:
あなたがレイアウトのFILL_PARENTパラメータを使用することができこれをチェックしてください:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
</LinearLayout>
あなたのボタンのそれぞれにウェイト1を追加して希望の効果を得てください
感謝をあなたのレイアウトxmlファイルのコードを投稿してください。したがって、各ボタンの幅は「FILL_PARENT」で、アクティビティのLinearLayoutはまだ「match_parent」ですか?ボタンに「ウェイト1を加える」とはどういう意味ですか?私がそれをすると、layout_width属性を指定する必要があり、ボタンが見えないと言います。 – Cole
この
<TableRow android:layout_width="fill_parent"
android:weightSum="100" android:layout_height="wrap_content">
<Button android:text="Button" android:layout_weight="25"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:layout_width="wrap_content"
android:layout_weight="25" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:layout_weight="25"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:layout_weight="25"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</TableRow>
を試してみてください。..とても速く答えるため – user370305