Add ripple effect to my button with button background color?

Here is another drawable xml for those who want to add all together gradient background, corner radius and ripple effect: <?xml version=”1.0″ encoding=”utf-8″?> <ripple xmlns:android=”http://schemas.android.com/apk/res/android” android:color=”@color/colorPrimaryDark”> <item android:id=”@android:id/mask”> <shape android:shape=”rectangle”> <solid android:color=”@color/colorPrimaryDark” /> <corners android:radius=”@dimen/button_radius_large” /> </shape> </item> <item android:id=”@android:id/background”> <shape android:shape=”rectangle”> <gradient android:angle=”90″ android:endColor=”@color/colorPrimaryLight” android:startColor=”@color/colorPrimary” android:type=”linear” /> <corners android:radius=”@dimen/button_radius_large” /> </shape> </item> </ripple> Add … Read more

Vertical line using XML drawable

Instead of a shape, you could try a View: <View android:layout_width=”1dp” android:layout_height=”match_parent” android:background=”#FF0000FF” /> I have only used this for horizontal lines, but I would think it would work for vertical lines as well. Use: <View android:layout_width=”match_parent” android:layout_height=”1dp” android:background=”#FF0000FF” /> for a horizontal line.

Programmatically set left drawable in a TextView

You can use setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom) set 0 where you don’t want images Example for Drawable on the left: TextView textView = (TextView) findViewById(R.id.myTxtView); textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon, 0, 0, 0); Alternatively, you can use setCompoundDrawablesRelativeWithIntrinsicBounds to respect RTL/LTR layouts. Tip: Whenever you know any XML attribute but don’t have clue about how … Read more

android:drawableLeft margin and/or padding

As cephus mentioned android:drawablePadding will only force padding between the text and the drawable if the button is small enough. When laying out larger buttons you can use android:drawablePadding in conjunction with android:paddingLeft and android:paddingRight to force the text and drawable inward towards the center of the button. By adjusting the left and right padding … Read more

Mipmap drawables for icons

There are two distinct uses of mipmaps: For launcher icons when building density specific APKs. Some developers build separate APKs for every density, to keep the APK size down. However some launchers (shipped with some devices, or available on the Play Store) use larger icon sizes than the standard 48dp. Launchers use getDrawableForDensity and scale … Read more