Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is new in Drawable Tinting in Android L Developer Preview compared to previous version?

Tags:

I am working of new Android L preview and now dealing with tinting concept on drawable.

I want to know if there is anything new regarding drawable tinting in Android L Developer Preview.

I read this this documentation which says:

The Android L Developer Preview enables you to define bitmaps or nine-patches as alpha masks and to tint them using a color resource or a theme attribute that resolves to a color resource (for example, ?android:attr/colorPrimary). You can create these assets only once and color them automatically to match your theme.

But I didn't understand how it is different from previous version. I know how to use ColorFilter or PorterDuffColorFilter to apply tint on image. Any help regarding this will be appreciated.

like image 985
BinaryGuy Avatar asked Aug 25 '14 09:08

BinaryGuy


People also ask

How do I find my pictures from the drawable folder on Android?

Then you can see the drawable folder under app —> res folder in the panel below the subview. Copy images from any directory you saved and right-click the drawable folder, click the Paste menu item in the popup menu list then accept all popup dialog. After that, you can see the images added in the drawable folder.

What is a drawable in Android?

A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.

Where is the drawable folder in Android Studio?

In Android Studio inside the res folder, one can find the drawable folder, layout folder, mipmap folder, values folder, etc. Among them, the drawable folder contains the different types of images used for the development of the application.


1 Answers

Starting in L, you can specify tints in XML. These can reference theme attributes (as shown), color state lists, color resources, or explicit hex color codes. By default, the tint mode is SRC_IN, but it can be set to something else using the android:tintMode attribute.

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/my_icon"
    android:tint="?android:attr/colorControlNormal" />

The default controls all use ?android:attr/colorControlNormal for their normal state (e.g. an unchecked check box) and ?android:attr/colorControlActivated (which maps to ?android:attr/colorAccent by default) for their activated state (e.g. a checked check box).

You can use these attributes in your own app drawables to inherit the default framework colors, or you can redefine them to change the default or activated control colors. You can also reference attributes specific to your app (as shown).

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/my_icon"
    android:tint="?attr/myThemeAttribute" />
like image 190
alanv Avatar answered Sep 18 '22 18:09

alanv