android-button

How to change the color of a button?

情到浓时终转凉″ 提交于 2021-01-20 16:19:09
问题 I'm new to android programming. How do I change the color of a button? <Button android:id="@+id/btn" android:layout_width="55dp" android:layout_height="50dp" android:layout_gravity="center" android:text="Button Text" android:paddingBottom="20dp"/> 回答1: You can change the colour two ways; through XML or through coding. I would recommend XML since it's easier to follow for beginners. XML: <Button android:background="@android:color/white" android:textColor="@android:color/black" /> You can also

Android button background is taking the primary color

拜拜、爱过 提交于 2021-01-20 07:13:32
问题 I've this issue, I don't know where it come from, I've created this buttons with custom background, but the background color talking the primary color and cannot change it unless change the primary color. <Button android:id="@+id/btn_teacher" style="@style/normalText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/_16sdp" android:background="@drawable/btn_rounded_stroke" android:text="@string/txt_teacher" /> <resources> <color name

Android button background is taking the primary color

拜拜、爱过 提交于 2021-01-20 07:09:19
问题 I've this issue, I don't know where it come from, I've created this buttons with custom background, but the background color talking the primary color and cannot change it unless change the primary color. <Button android:id="@+id/btn_teacher" style="@style/normalText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/_16sdp" android:background="@drawable/btn_rounded_stroke" android:text="@string/txt_teacher" /> <resources> <color name

Android material button taking color primary instead of color accent

跟風遠走 提交于 2021-01-07 01:21:34
问题 I have my layout button as - <com.google.android.material.button.MaterialButton android:id="@+id/save_button" style="@style/buttonView" android:text="Save" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" /> In my styles.xml , I have - <style name="buttonView" parent="Theme.MyTheme"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_marginStart">16dp</item> <item

background color on Button in Jetpack Compose

假装没事ソ 提交于 2020-12-15 03:42:41
问题 Button(backgroundColor = Color.Yellow) { Row { Image(asset = image) Spacer(4.dp) Text("Button") } } I can not figure out why I can't use background color on Button I followed on Compose Layout codelabs there is a problem in backgroundColor and asset in Image(). Please help me figure out how to use Buton, I'm still new 回答1: The backgroundColor for Button no longer work in 1.0.0-alpha7 Use the below instead Button( onClick = {}, colors = ButtonConstants.defaultButtonColors(backgroundColor =

Android Background Drawable Not Working in Button Since Android Studio 4.1

狂风中的少年 提交于 2020-11-25 03:32:52
问题 I find out that since Android Studio 4.1 I cannot change the background color of a Button by setting color on its android:background , just no effect. And custom Drawable is not working as well. My background Drawable : <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1.5dp" android:color="@android:color/black" /> <solid android:color="@android:color/white" /> <corners android:radius="8dp" /> </shape> My Button : <Button

Android Background Drawable Not Working in Button Since Android Studio 4.1

北战南征 提交于 2020-11-25 03:30:19
问题 I find out that since Android Studio 4.1 I cannot change the background color of a Button by setting color on its android:background , just no effect. And custom Drawable is not working as well. My background Drawable : <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1.5dp" android:color="@android:color/black" /> <solid android:color="@android:color/white" /> <corners android:radius="8dp" /> </shape> My Button : <Button

Android Background Drawable Not Working in Button Since Android Studio 4.1

雨燕双飞 提交于 2020-11-25 03:29:38
问题 I find out that since Android Studio 4.1 I cannot change the background color of a Button by setting color on its android:background , just no effect. And custom Drawable is not working as well. My background Drawable : <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1.5dp" android:color="@android:color/black" /> <solid android:color="@android:color/white" /> <corners android:radius="8dp" /> </shape> My Button : <Button