我希望在button
上使用多行文字,但多重衬里使其略微向下移动
如何解决?
以下是Button
的XML代码: -
<TableLayout
android:id="@+id/tab_buttons"
android:layout_width="368dp"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp">
<TableRow>
<Button
android:id="@+id/clock"
android:background="#BAFFBA"
android:text="@string/clock" />
<Button
android:id="@+id/Alarm"
android:text="@string/Alarm"
android:background="#004819"
android:textColor="#FFFFFF"
/>
<Button
android:id="@+id/stopwatch"
android:background="#BAFFBA"
android:text="@string/Stopwatch" />
<Button
android:id="@+id/timer"
android:background="#BAFFBA"
android:text="@string/Timer" />
</TableRow>
</TableLayout>
这是string
秒表: -
<string name="Stopwatch">Stop Watch</string>
答案 0 :(得分:1)
<LinearLayout
android:id="@+id/tab_buttons"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button
android:background="#BAFFBA"
android:id="@+id/clock"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dp"
android:text="@string/clock" />
<Button
android:background="#004819"
android:id="@+id/Alarm"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dp"
android:text="@string/Alarm"
android:textColor="#FFFFFF" />
<Button
android:background="#BAFFBA"
android:id="@+id/stopwatch"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dp"
android:text="@string/Stopwatch" />
<Button
android:background="#BAFFBA"
android:id="@+id/timer"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dp"
android:text="@string/Timer" />
</LinearLayout>
答案 1 :(得分:1)
<TableLayout android:id="@+id/tab_buttons"
android:layout_width="368dp"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<TableRow>
<Button
android:id="@+id/clock"
android:background="#BAFFBA"
android:text="CLOCK" />
<Button
android:id="@+id/Alarm"
android:text="ALARM"
android:background="#004819"
android:textColor="#FFFFFF"
/>
<Button
android:id="@+id/stopwatch"
android:background="#BAFFBA"
android:layout_height="match_parent"
android:text="Stop Watch" />
<Button
android:id="@+id/timer"
android:background="#BAFFBA"
android:text="TIMER" />
</TableRow>
</TableLayout>
只需将android:layout_height="match_parent"
应用于秒表按钮。