Where can i found default android xml drawables? - android

I would like to use the default ice cream sandwich radio button but not with ligth blue color. I would like to recolor it.
Can i somewhere found the original .xml files to recolor and use it in my project?

Look in your SDK folder, API-Level, under data/res/drawable

Take a look in the Android sources:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res
Most of the drawables use styles, so you can just change the colors by setting styles in your app.
Like here:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml

Related

How to change icon colors in android studio

I downloaded some icons from material.io but they only offer the icons in black. I saw a youtube video where they use to allow you to choose the color. Anyway, I am trying to change the colors of the icons to white. I am not having any luck. I tried to change the fill color in android studio but it doesn't work. Any assistance would be appreciated such as exact code and files to add the code to. Thanks.
simply you can use
android:tint="#android:color/white"
You can directly download these images in Android Studio.
res > right click > New > Image Asset and select
Icon Type : Action Bar and Tab Icones
Asset Type : Clip Art
Theme : CUSTOM
And you can select any clip art that you want, select the color, padding, etc ...
As mentioned before, the material.io icons can be downloaded directly with Android Studio. This solution shows the importing of vector asset icons which are easier to manage since they are stored in a single location (res/drawable) vs. image assets that will have each icon stored in specific density folders (hdpi, xhdpi, etc).
expand the "res" folder
right click drawable
hover over "new"
select "Vector Asset"
click the image next to "icon"
select desired material.io icon
Name the icon what you would like
select "next"
Now you will have two options of setting the icon color
In the layout by using the android:tint attribute of an ImageView. This is my preference because the icon can be viewed prior to runtime.
or
In Java.
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.MULTIPLY);
https://material.io/icons/ actually does let you download icons in white.
But, depending on what exactly you want to do, there are a few options. If you simply want white icons (and not to change them at runtime), you may find this plugin for Android Studio useful: https://github.com/konifar/android-material-design-icon-generator-plugin
It allows you to generate the material design icons right in Android Studio, in whatever color you want. Another alternative for downloading these icons in different colors is https://materialdesignicons.com/.
If you do want to color the icons at runtime, try something like this:
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.MULTIPLY);
You can download white icons from material.io. also look at themes and theme overlays
Instead of android:src
I use attribute android:foreground
android:foreground="#drawable/ic_add"
For those not getting what they want yet try changing the PorterDuff mode, the following is what did it for me
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.SRC_ATOP);
maybe
app:iconTint help you, I am writing this because of the following reference.
Material Design 3

How to create a background selector that has Kitkat style for pre-Lollipop, and native one for Lollipop and above?

This question is short.
How do I set a background for buttons and such, that will have the native look&feel of Lollipop (ripple etc...) for Lollipop and above, and Kitkat style for Kitkat and below?
I ask this to make this library look better:
https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary
I think this is possible by declaring the different 'styles' in the corresponding 'values' folder. I think the following link can help:
http://developer.android.com/training/material/compatibility.html#Theme

how do I use textfield_default_holo_dark.9.png

I'm using a textview in a dark background so I'd like to use the light colored 'holo light' themed items in my activity instead of the defaults. In the past I've copied these from the android source to my own res directories. There must be a better way but I haven't found it so far. Suggestions please...

How to create ICS holo style edit text for older versions?

I have searched lot of sites for creating ICS holo style EditText in Android older versions. But the results did not helped me. Please provide me some sample links/code.
Copy the images from the android-sdk folder, and use them.
Search here for textfield_bg_*
/android-sdks/platforms/android-16/data/res/drawable-mdpi
Basically you want to download this xml selector drawable and put it as the background of each EditText:
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable/edit_text_holo_light.xml
(If you want holo dark then just replace each instance of "light" with "dark", obviously.)
Then you need to find each of the drawables referenced in that selector and download them into your res folder in the appropriate size category. You can use that github project to search for them - for example, the xhdpi version of textfield_multiline_default_holo_light can be found at https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable-xhdpi/textfield_multiline_default_holo_light.9.png
You should probably use the HoloEveryWhere Library. It allows you to use the Holo themes on older API levels.

Styled Toggle Buttons in Android

I was reading the tutorial on Styling the Android toggle button here. The author asks us to create the 9patch drawable for both. I have trying to do this all morning, but have not been able to. Could anyone share the images with me, or tell me where i can get them ?
Kind Regards
You can find the 9patch drawable tool in the SDK folder in the tools folder.
It's a very useful tool for creating 9patch images, and you should be able to make your toggle button with it
There are links to 9-patches here: https://stackoverflow.com/a/15640365/2066079
The ones provided will style your togglebuttons to look like switches (which are only available in v14+)

Categories

Resources