Android 无法将形状应用于按钮
我有一个奇怪的问题。我创建了一个简单的Android 无法将形状应用于按钮,android,android-layout,button,Android,Android Layout,Button,我有一个奇怪的问题。我创建了一个简单的按钮,如下所示: <com.google.android.material.button.MaterialButton android:id="@+id/continue_button" android:background="@drawable/green_button_selector" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_ma
按钮
,如下所示:
<com.google.android.material.button.MaterialButton
android:id="@+id/continue_button"
android:background="@drawable/green_button_selector"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/landing_margin"
android:layout_marginEnd="@dimen/landing_margin"
android:layout_marginBottom="@dimen/landing_margin"
android:text="@string/login_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
但是我的按钮没有变绿,而是有我的应用程序的颜色重音,你知道我做错了什么吗?如果你使用的是材质按钮,你不需要创建自定义可绘制的
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:backgroundTint="@android:color/holo_green_dark"
app:cornerRadius="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="BUTTON" />
更多信息:
您可以在下面的属性中进行相同的操作
app:cornerRadius
应用程序:背景色调
阅读更多
当您创建新的可绘制项目时,重建项目不会立即添加。我尝试了它,但不幸的是它没有效果。您的可绘制工作正常,我认为您的约束布局出现了问题。尝试设置宽度并检查。我认为边距和宽度造成了问题。您找到解决方法了吗?
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:backgroundTint="@android:color/holo_green_dark"
app:cornerRadius="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="BUTTON" />
<com.google.android.material.button.MaterialButton
android:id="@+id/material_text_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/outlined_button_label_enabled"/>