Is there any way to create custom drawable folders based on themes? - android

I have one theme -> theme1
it has to pick the drawable from the drawable-theme1 folder.
is there any way?

Currently there is no way to use a theme name as drawable folder qualifier
The available qualifiers are in the table 2 at this link:
https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources
If you can't find a valid alternative using the provided ones maybe you should think if a "drawable-theme" folder is the right approach to solve your problem

Related

Proper way to override values-night for different OS versions

I want to implement night mode in my app. I referred to this site:
DayNight Theme Android Tutorial with Example
I see we need to make the values-night directory and override the styles.xml file inside it. I already have other different values directory like values-v27 also overriding the styles.xml file. How do I implement the night theme for those specific directories? Like is it values-v27-night or is it values-night-v27? Is it even possible?
Of course you can have specific values for the night and for any other resource qualifier. For your example, the resource directory name will be values-night-v27.
If you are unsure of the order, you can right click the res node in your project structure and go to New > Android Resources Directory, then fill you criteria and the name will be automatically generated.
values-night-v27 puts an and clause between two conditions v27 and night , so it doesn't matter if you use values-v27-night.
Also if you put your values separately in values-v27 and values-night an or clause will be applied

Where are the drawables or clipart from android.R.drawable stored?

I am integrating ActionBarSherlock in my app and I want to have some menus with some items and its respective icons.
I have looked into samples and documentation, and everything seems to be clear, but when I Inflate the menu, I can see just the text because there are no icons related to each item yet.
I would like to use the icons you see when creating an android project:
But I can't find it, and I don't want to use direct reference to android.R.drawable in order to use those clipart icons, because I have read it is recommended to have the files in drawable folders.
android-sdk/platforms/android-xx/data/res/drawable-yyyy
where xx is your target platform and yyyy is mdpi, hdpi, etc.
Copy the icons you want into the appropriate resource folder in your project.
I generally use Android Asset Studio to create icons for my apps. It has all the standard clipart, and can generate the proper files for all other icons as well.
http://developer.android.com/design/downloads/index.html site has Action Bar Icon Pack
You can use system icons by using "#android:" prefix. The icon is not copied to drawable folders, so the application size is smaller"
Example: android:icon="#android:drawable/ic_menu_preferences"
List of icons at /platforms/android-/data/res/drawable-hdpi
Note 1: If you want to copy the icons to drawable files you can also do it in eclipse by using file /new/other/Anddoid icon set/clipart button/choose button.
Note 2: the icon set could change among platforms. That is why people are suggesting to copy resources. If the applicacion is just at development state you could just link the platform icons

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.

Is there any way to use not public android resources in my application?

I need to use the following resources in my widget:
pressed_application_background_static
focused_application_background_static
I hope that usage of these resources will allow me to have orange background on standard android and green on HTC.
But they are not public, so usage of
android:drawable="#android:drawable/pressed_application_background_static"
is not allowed. Is still there any way to use them?
You can reference them like this
android:drawable="#*android:drawable/pressed_application_background_static"
but it is not recommended, because private resources are likely to be renamed or removed in the future.
browse the sdk for the drawable and copy it locally to you res/drawable folder. it will probably be an XML file but if you search for "pressed_application_background_static" you should find it without trouble.

Android: Use different drawables after choosing a different theme, keeping the same references

Is possible to make the app use different drawables after choosing a theme in Android?
An explanatory example:
i have a layout which background uses a reference to: "#drawable/backgroundsolid", that is image backgroundsolid.png in res/drawable-mdpi.
I want that, if the user choose "Glass" theme, the reference stays to "#drawable/backgroundsolid" but the resources folder is changed to res/drawable-glass, which contains a different backgroundsolid.png image.
Is it possible to set this programmatically? Thanks a lot!
You can set it programmatically by using view.setBackgroundResourceId(). I am not sure if you do it the other way which is let android pick the right theme for you. Maybe someone else has a better answer

Categories

Resources