How to set a gradient background to a Material Button?

To use a custom drawable background with the MaterialButton you can use the android:background attribute: <MaterialButton app:backgroundTint=”@null” android:background=”@drawable/bkg_button_gradient” … /> NOTE: It requires at least the version 1.2.0-alpha06 Currently it is very important to add app:backgroundTint=”@null” to avoid that the custom background doesn’t get tinted by default with the backgroundTint color. With lower versions of … Read more

how to change a drawableLeft icon size on a button?

Wrap your resource in a drawable that defines your desired size similar to: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item android:drawable=”@drawable/icon” android:width=”@dimen/icon_size” android:height=”@dimen/icon_size” /> </layer-list > After that, use this drawable in your android:drawableLeft tag

Changing color in a shape inside a layer-list programmatically

Ok I found the answer, I just had to put the id of the shape inside the item not in the shape kachel_ticked_style.xml: <item android:id=”@+id/selectable_kachel_shape”> <shape android:shape=”rectangle” > <stroke android:width=”5dp” android:color=”@color/headrbar_color” /> </shape> </item> And then you can change either the color of the shape calling shape.setColor or the color of the stroke calling shape.setStroke(strokeWidth,strokeColor)

Android: How to Make A Drawable Selector

You can add this in Android Studio, use Right click on project structure -> New -> Drawable resource file. It should look like this: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_enabled=”false” android:drawable=”@drawable/cell_top_selected” /> <item android:drawable=”@drawable/cell_top” /> </selector>

How to remove Black background between start new activity during slide_left animation?

Setting the Theme didn’t work for me, but adding an exit animation did. overridePendingTransition (R.anim.push_up_in,R.anim.hold); For the exit animation, I just used an animation that does nothing. <?xml version=”1.0″ encoding=”utf-8″?> <set xmlns:android=”http://schemas.android.com/apk/res/android”> <translate android:fromYDelta=”0%p” android:toYDelta=”0%p” android:duration=”2000″/> </set>

How to draw a circle inside a circle using Android xml shapes?

The only way I’ve gotten this to work is to define a transparent stroke for the inner (i.e., top) circle that’s the difference between the size of the larger and smaller circle. For example, this: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <!– Larger blue circle in back –> <item> <shape android:shape=”oval”> <solid android:color=”#00f”/> <size android:width=”15dp” android:height=”15dp”/> … Read more

How Do I Use ‘RotateDrawable’?

here’s a nice solution for putting a rotated drawable for an imageView: Drawable getRotateDrawable(final Bitmap b, final float angle) { final BitmapDrawable drawable = new BitmapDrawable(getResources(), b) { @Override public void draw(final Canvas canvas) { canvas.save(); canvas.rotate(angle, b.getWidth() / 2, b.getHeight() / 2); super.draw(canvas); canvas.restore(); } }; return drawable; } usage: Bitmap b=… float angle=… … Read more

Add gradient to imageview

You need two layers: An ImageView, and a View on top of that with your gradient as android:background. Put these two Views in a FrameLayout: <FrameLayout … > <ImageView … android:src=”https://stackoverflow.com/questions/23991395/@drawable/trend_donald_sterling” /> <View … android:background=”https://stackoverflow.com/questions/23991395/@drawable/trending_gradient_shape”/> </FrameLayout>

Style bottom Line in Android

It’s kind of a hack, but I think this is probably the best way to do it. The dashed line will always be on the bottom, regardless of the height. <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item> <shape android:shape=”rectangle” > <solid android:color=”#1bd4f6″ /> </shape> </item> <item android:top=”-2dp” android:right=”-2dp” android:left=”-2dp”> <shape> <solid android:color=”@android:color/transparent” /> <stroke android:dashGap=”10px” android:dashWidth=”10px” android:width=”1dp” android:color=”#ababb2″ /> … Read more