Modifying the color of an android drawable

So after a lot of trial and error, reading different articles, and most importantly, going through the API Demos (ColorFilters.java — found in com.example.android.apis.graphics) I found the solution. For solid images, I have found it is best to use the color filter PorterDuff.Mode.SRC_ATOP because it will overlay the color on top of the source image, … Read more

How to set status bar background as gradient color or a drawable in Android?

For some one who want to set gradient color to status bar background you can use following method in your activity before setContentView() For Java @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void setStatusBarGradiant(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); Drawable background = activity.getResources().getDrawable(R.drawable.gradient_theme); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent)); window.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent)); window.setBackgroundDrawable(background); } } For Kotlin @TargetApi(Build.VERSION_CODES.LOLLIPOP) fun … Read more

Newer versions of Android Studio add only two drawable directories – drawable and drawable-v21

Thank you to everyone who tried to help. You helped me reach the final answer, but no one solution was quite right. @user3137702 was probably the closest, as it IS related to the whole move to vectors/SVGs. I couldn’t find a definitive answer, like something directly from Google (although I imagine it is out there), … Read more

Half circle shape not work

you can try this : <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <solid android:color=”#900021df”/> <size android:width=”10dp” android:height=”5dp”/> <corners android:bottomLeftRadius=”20dp” android:bottomRightRadius=”20dp”/> </shape> it gives this shape:

How to support all the different resolutions of android products

You don’t have to do that to support different densities. What you do is create different resources folders: res/values-ldpi/dimens.xml res/values-mdpi/dimens.xml res/values-hdpi/dimens.xml Then Android will decide which file to use. You can have something like: <!– in values-ldpi/dimens.xml –> <dimen name=”textSize”>25dip</dimen> and.. <!– in values-mdpi/dimens.xml –> <dimen name=”textSize”>20dip</dimen> etc. And you shouldn’t care about resolution… there … Read more

How to set foreground attribute to other non FrameLayout view

The idea is to surround your layout with a FrameLayout, and set the selector and the onClick event to this layout. <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/selectableItem” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:foreground=”@drawable/foreground_row” > <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/cardContent” android:layout_width=”match_parent” android:layout_height=”match_parent” android:background=”@drawable/row_background”> … </RelativeLayout> </FrameLayout> You can find a full explanation at my blog: http://antonioleiva.com/unveiling-bandhook-foreground-any-layout/ Or you can extend rhis FRelativeLayout https://gist.github.com/shakalaca/6199283

Styling EditText view with shape drawable to look similar to new holographic theme for Android < 3.0

It’s a little hack, but unless you find something better, this way it should be possible. <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item> <shape > <solid android:color=”@color/border” /> </shape> </item> <!– main color –> <item android:bottom=”1.5dp” android:left=”1.5dp” android:right=”1.5dp”> <shape > <solid android:color=”@color/background” /> </shape> </item> <!– draw another block to cut-off the left and right … Read more