android studio 中带有多行文本的按钮在下方稍微移动了一点
Button with multi line text is little bit shifted below in android studio
我想在 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>
<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>
<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"
应用于秒表按钮。
我想在 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>
<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>
<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"
应用于秒表按钮。