0
私はAndroidアプリのレイアウトに関して奇妙な問題があります(私はそれを学んでいますので、私は電卓を作っています:))。私はすべてのボタンが行の幅の25%になるように指定しましたが、最初にEditTextを追加すると、最初の列は他の3つの列よりも大幅に広くなります。 (スクリーンショットはIntelliJプレビューのものですが、デバイスにアプリケーションをロードすると同じ結果が表示されます。奇妙なレイアウトの動作 - レイアウト_重量とボタン
EditTextを削除すると、この問題は解消されます。XMLのEditTextにウェイト属性を追加しようとしました。無駄ない
結果:。
マイコード:中
<?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">
<TableLayout android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:weightSum="1.0">
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<EditText android:layout_weight="1.0"
android:text="Edit me"></EditText>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<Button android:text="7"
android:layout_weight="0.25"></Button>
<Button android:text="8"
android:layout_weight="0.25"></Button>
<Button android:text="9"
android:layout_weight="0.25"></Button>
<Button android:text="/"
android:layout_weight="0.25"></Button>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<Button android:text="4"
android:layout_weight="0.25"></Button>
<Button android:text="5"
android:layout_weight="0.25"></Button>
<Button android:text="6"
android:layout_weight="0.25"></Button>
<Button android:text="*"
android:layout_weight="0.25"></Button>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<Button android:text="1"
android:layout_weight="0.25"></Button>
<Button android:text="2"
android:layout_weight="0.25"></Button>
<Button android:text="3"
android:layout_weight="0.25"></Button>
<Button android:text="-"
android:layout_weight="0.25"></Button>
</TableRow>
<TableRow android:layout_width="fill_parent">
<Button android:text="0"
android:layout_weight="0.25"></Button>
<Button android:text="."
android:layout_weight="0.25"></Button>
<Button android:text="+/-"
android:layout_weight="0.25"></Button>
<Button android:text="="
android:layout_weight="0.25"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
感謝dvance。
これはうまくいくはずです。あなたは早かったよ: –
ゴールデン!オリエンテーションを忘れてしまったので、私はこのように気付かなかったのです。ありがとう。 – Hidde