【发布时间】:2021-08-19 10:05:05
【问题描述】:
我想知道如何在按钮之间垂直添加空间,我在跟着教练,他屏幕上的按钮看起来不错。另外,当我下载他的项目文件时,问题仍然存在。
我是 XML 中这种权重技术的新手。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:id="@+id/tvInput"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#EFEFEF"
android:textSize="48sp"
android:maxLength="12"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
android:id="@+id/btnSeven"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="7"
android:onClick="onDigit"
/>
<Button
android:id="@+id/btnEight"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="8"
android:onClick="onDigit"
/>
<Button
android:id="@+id/btnNine"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="9"
android:onClick="onDigit"
/>
<Button
android:id="@+id/btnDivide"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="/"
android:onClick="onDigit"
/>
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
尝试用 androidx.appcompat.widget.AppCompatButton 替换 Button
标签: java android android-studio kotlin android-activity