【发布时间】:2021-04-12 03:53:42
【问题描述】:
我该怎么做?
【问题讨论】:
-
从你的图片看,它看起来在'下面' TextView 不是'in'。
标签: android-studio android-layout android-layout-editor
我该怎么做?
【问题讨论】:
标签: android-studio android-layout android-layout-editor
如果您想要一个带有圆形 textView 的按钮,那么我就是这样做的。请注意,我在这里使用com.google.android.material 以获得我想要的最快结果。
<com.google.android.material.button.MaterialButton
android:id="@+id/button"
android:backgroundTint="@android:color/holo_red_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="start"
app:cornerRadius="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
这就是它在我的 IDE 上的样子。
【讨论】:
您可以简单地使用Button 组件。但是如果你想拿TextView 那么:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/start_btn_bg"
android:text="start"
android:paddingHorizontal="30dp"
android:paddingVertical="10dp"/>
您可以通过使自定义可绘制来设置背景。 下面是自定义drawable:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@color/color_red_error"
android:centerColor="@color/color_red_error"
android:endColor="@color/colorAccent"/>
<corners android:radius="20dp" />
【讨论】:
start_btn_bgsn-p :)