How to create rounded border Button using Jetpack Compose

To achieve a button with a border with rounded corners you can use the OutlinedButton component applying in the shape parameter a RoundedCornerShape: OutlinedButton( onClick = { }, border = BorderStroke(1.dp, Color.Red), shape = RoundedCornerShape(50), // = 50% percent // or shape = CircleShape colors = ButtonDefaults.outlinedButtonColors(contentColor = Color.Red) ){ Text( text = “Save” ) … Read more

android – How can I make a button flash?

There are several, depending on what kind of flashing you mean. You can, for example, use alpha animation and start it as your button first appears. And when the user clicks button, in your OnClickListener just do clearAnimation(). Example: public void onCreate(Bundle savedInstanceState) { final Animation animation = new AlphaAnimation(1, 0); // Change alpha from … Read more

implement android:src=”@drawable/image” programmatically in Android

Try this: ImageButton btn = (ImageButton)findViewById(R.id.button1); btn.setImageResource(R.drawable.newimage); where newimage is the image name in drawable folder. EDITED try this: ImageButton btn = (ImageButton)findViewById(R.id.button1); btn.setImageBitmap(bm); where bm is bitmap extracted from server. EDITED AGAIN I see you receive a Drawable; well, do this: normalImage = Drawable.createFromStream(code); Bitmap bm = ((BitmapDrawable)normalImage).getBitmap(); ImageButton btn = (ImageButton)findViewById(R.id.button1); btn.setImageBitmap(bm);

Android Background Drawable Not Working in Button Since Android Studio 4.1

The Android Studio 4.1 new-project wizard, for many of its templates, has the project use the Material Components for Android library. And, it sets up the default theme to be based on Theme.MaterialComponents.DayNight.DarkActionBar. A side effect of this is that any <Button> elements in a layout get turned into MaterialButton widgets, not regular Button widgets. … Read more

Disabled color state of Material button

Create the folder /res/color (in your res directory). Add a new color resource file here, named something like color_states_materialbutton.xml: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_enabled=”false” android:color=”@color/colorDisabled” /> <item android:color=”@color/colorEnabled” /> </selector> Create a style in styles.xml with one of the Widget.MaterialComponents.Button styles as its parent and your color state list as the backgrountTint tag: … Read more

background color on Button in Jetpack Compose

Use ButtonDefaults which is available in 1.0.0-alpha09 to alpha11 Button( onClick = {}, colors = ButtonDefaults.buttonColors(backgroundColor = Color.Yellow) ) { /**/ } OLD VERSION The backgroundColor for Button no longer work in 1.0.0-alpha7 Use the below instead Button( onClick = {}, colors = ButtonConstants.defaultButtonColors(backgroundColor = Color.Yellow) ) { /**/ }

Material design button with border

You can also use the Material Components for Android. Add the dependency to your build.gradle: dependencies { implementation ‘com.google.android.material:material:1.3.0’ } In this case you can use the MaterialButton in your layout file: <com.google.android.material.button.MaterialButton …. style=”@style/Widget.MaterialComponents.Button.OutlinedButton” app:cornerRadius=”..” app:strokeColor=”@color/colorPrimary”/> Apply the style @style/Widget.MaterialComponents.Button.OutlinedButton. In your case use the app:cornerRadius attribute to change the size of corner radius. … Read more

Rounded corners on material button

With the Material Components Library:. Add the dependency to your build.gradle: dependencies { implementation ‘com.google.android.material:material:1.3.0’ } In this case you can use a MaterialButton in your layout file: <com.google.android.material.button.MaterialButton …. style=”@style/Widget.MaterialComponents.Button” app:cornerRadius=”..” app:strokeColor=”@color/colorPrimary”/> Use app:cornerRadius attribute to change the size of corner radius. This will round off the corners with specified dimensions. You can also … Read more

How to custom switch button?

However, I might not be taking the best approach, but this is how I have created some Switch like UIs in few of my apps. Here is the code – <RadioGroup android:checkedButton=”@+id/offer” android:id=”@+id/toggle” android:layout_width=”match_parent” android:layout_height=”30dp” android:layout_marginBottom=”@dimen/margin_medium” android:layout_marginLeft=”50dp” android:layout_marginRight=”50dp” android:layout_marginTop=”@dimen/margin_medium” android:background=”@drawable/pink_out_line” android:orientation=”horizontal”> <RadioButton android:layout_marginTop=”1dp” android:layout_marginBottom=”1dp” android:layout_marginLeft=”1dp” android:id=”@+id/search” android:background=”@drawable/toggle_widget_background” android:layout_width=”0dp” android:layout_height=”match_parent” android:layout_weight=”1″ android:button=”@null” android:gravity=”center” android:text=”Search” android:textColor=”@color/white” /> … Read more

How to add buttons at top of map fragment API v2 layout

Maybe a simpler solution is to set an overlay in front of your map using FrameLayout or RelativeLayout and treating them as regular buttons in your activity. You should declare your layers in back to front order, e.g., map before buttons. I modified your layout, simplified it a little bit. Try the following layout and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)