I managed to get my adaptive icons working by creating a folder mipmap-anydpi and placing suggested xml file there (https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive.html#studio)
This worked on api 26, but broke icons on android versions lower than that, they now show default android image. I managed to fix this by renaming my folder to mipmap-anydpi-v26, now icons work as expected on all supported apis.
My question is this, are we supposed to do it like this? Will -v26 make it also work on api 27+ or I have to create separate -v2X folder for each future api?
When you create a folder or a ressource file for a specific screen density or android version, this file becomes, in your case, the default reference for this version and the versions above.
Hope this helps.
Related
I already made the layout.xml in the layout folder, but for a small device its not working
than = then =x
and after reading some articles, i must create a layout-small isnt it?
so im trying to do in android studio, it dont allow me saying that it already exist, BUT there is not layout-small folder =/ i should i do?
EDIT*
i already tried to create a folder manually in windows and restart android studio, not working too...
what i saw is that while gradle is building, i show all the folders, but after gradle finishes, it HIDE the folder
Look:
WHILE BUILDING:
AFTER BUILDING:
It may be a little bit stupid, but did you try creating this folder manually using Windows? If it is already, maybe restart Android Studio?
Also Screen Support
Note: Beginning with Android 3.2 (API level 13), these size groups are deprecated in favor of a new technique for managing screen sizes based on the available screen width. If you're developing for Android 3.2 and greater, see Declaring Tablet Layouts for Android 3.2 for more information.
I have created a navigation drawer in my project of android 4.1 version. Now I have added backward support to froyo as well in my app using the support libraries. But in the drawer_list_item xml file, it is showing some error in these lines, when I try to run it on gingerbread.
1) android:minHeight="?android:attr/listPreferredItemHeightSmall"
2) android:textAppearance="?android:attr/textAppearanceListItemSmall"
I have found from another website that the line 1 is only available on API 11+ and line 2 is only available on API 14+. So my question is, Is there any other alternative to these two lines of code, which makes my code run on lower version devices such as gingerbread as well. Now when I try to remove these two lines of code from my xml file, the app runs file, but the navigation drawer list items are not properly displayed correctly. So I need an alternative for the lines 1 & 2 for my project. Any help from any one is easily appreciated. Thanks in advance..
because those are values you can replace them by your own custom attributes, to find more about them look at
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml#L123
which you can find corresponding values. you can create your own attribute files to run on any device without
any version restriction by using the values from above link and creating XML attribute file. in order to find
how to create attribute file look at google doc.
I wanted to use Theme.Wallpaper in my app. This theme uses the phones current wallpaper as a background. The problem is it doesn't work on a 4.1 device. I also tried recreating the Theme.Wallpaper in my style resources but again it doesn't work for 4.1 devices.
- note that it may not work for lower APIs as well, I only confirmed it working on 2.2.1 and not working on 4.1.
I would like to know why it doesn't work and if there is any solution to that.
I have finally found the answer, it's a bit complex:
In a project built for a target above 14 (mine is 17) eclipse automatically creates a "values-v11" and a "values-v14" folders (applyed for phones or AVDs with api version 14 and above or 11 and above). In those folders are style.xml files that contain the "AppBaseTheme" style, This "AppBaseTheme" style replaces the one in the default "values" folder, which is the parent of (or: is extended by) the "AppTheme" style that is applyed by default to the application..
Now, the way I chose to apply the "Theme.Wallpaper" style to my app, was to have my "AppBaseTheme" inherit from it. Understanding this, it became obvious why my app did not have a "Theme.Wallpaper" like behavior on Systems with API 11 and above: I never made the alternative v11 and v14 "AppBaseTheme" extend the "Theme.Wallpaper" or the more suitable "Theme.Holo.Wallpaper" for v11, and "Theme.DeviceDefault.Wallpaper" for v14.
So, if you have troubles with applying styles, I hope you see this...
EDIT: if your reading this, and have troubles with editing the style.xml file in eclipse, try opening this file in any text editor (my favorite is notepad++) and just delete all the comments than reopen it on eclipse. In case you need comments just add them afterwords on your text editor.
Well, lately i've been coding an app using 2.3 emulator, I was mainly testing the app in 2.3.7 phone, but yesterday I updated my phone to android 4.0.3 and the UI looks like shit, in fact, keeps the "bad" looking 2.3 UI.
Now i'm trying to get a nice looking app in both versions of android, the problem is that i don't want to have 2 separate projects an edit both of them, so i want to use one single project and 2 virtual machines for the different versions.
The problem is that if i create a project destinated to 2.3 i can't call to HOLO Theme resources, and if I create a 4.0.3 project it will not even work in android 2.3 right?
so... what do i need to do?
thanks.
You need to set the targetSDKVersion as 15, minSDKVersion as 10.
You need to create various resource folders for these two versions. Example, create a folder 'values-v14' inside 'res' folder and define your widget styles for ICS. Have another folder 'values-v10' and keep your styles for 2.3.3
If required, use the version qualifiers to define separate layout for different versions.
The below links will give you more clear idea.
http://developer.android.com/training/basics/supporting-devices/platforms.html
http://developer.android.com/training/backward-compatible-ui/index.html
In this linked image , I see the button on the right quite often in a lot of apps. On my Moto Droid, it is used extensively in the settings app. It is also used as the default AlertDialog icon. Can I use this via a android.r.drawable?
The icon is built-in with the Android development, you can access the image by using R.drawable.ic_dialog_menu_generic
While it may be possible to use it via android.R.drawable, you may want to find the image in the resources that come with your SDK ($ANDROID_HOME/platforms/$VERSION/data/res, where $ANDROID_HOME is where you have the SDK installed and $VERSION is a relevant Android API level). So, per Mr. Forloney's answer, you'll find that in, say, drawable-hdpi/ic_dialog_menu_generic.png in the aforementioned directory. Then, copy that image into your project. While it will add 5K to your project size, it will mean that the icon does not change based upon OEM or Android changes.