I am new in android development. And I have confusion about android layout compatibility.
I am creating one app in android 4.0.3 but it's UI look like android 2.2 related UI.
I used all default controls in app but it not look like 4.0.3 related UI.
So any one can help me in below problems.
If I am creating app in android 4.0.3 then how it's look in android 2.2 and vice versa?
How can I create app which is run in all android version with standard UI?
Please help me.
Thanks in advance.
Your app will use the system theme that you specify, or the custom styles that you specify. If you do not create custom themes or styles your app will use the default styles on each platform. So on 4.0.3 it will use the ICS theme, and on 2.2 it will use the older theme.
To create an app that will run on all versions, you should probably set your target API to 1.5, but there are few devices with 1.5 left, so you'll probably set your API target to 2.2, and this will make your application run on all the devices with Android 2.2+.
Related
I am developing and Android app for my Android 12 device. Naturaly, I want the UI to match the new Material 3 design.
However, how are older devices handled? How can I make my app look native on Android 11 as well?
Currently I have MDC version 1.5.0 as a dependency for my project. As far as I understood, this makes the UI always look like Material 3, independent of which device it runs on.
I wanna create theme for both Android 5.0 and less android 5.0 application.
In first case for example I have Switch that if I don't set any background it appearance will change on Android 5.0 to like a slide button as you know,
but in less android 5.0 it show as on/off button.
when I put
android:thumb="#drawable/switch_selector"
to change thumb image and color it's fine on android 4.4 but my Switch show nothing on Android 5.0. my question is how to create a selector or theme for Switch that can show on all devices?
UPDATED
in simple way, we hava many drawable folders for each screen dpi's. I wanna know if I can set drawable for each Api's as like as for each dpi's ?!
after my hard times with Android notifications, where I need to do one method for android devices with Android 5.x and higher and another method for pre-Lollipop devices, I would advice you to search for additional libraries like this
SwitchButton
This project provides you a convenient way to use and customise a SwitchButton widget in Android. With just resources changed and attrs set, you can create a lifelike SwitchButton of Android 5.0+, iOS, MIUI, or Flyme and so on.
Now we get the biggest movement since SwitchButton published. v1.3.0 comes with totally reconsitution and more convenient API. A wholly new demo can give you a tour in it.
Github page: https://github.com/kyleduo/SwitchButton
More like this you would find here: http://android-arsenal.com/
Additional libraries may help you to avoid problems with backward compatibilities of Android components.
Like you said, you add this line of code:
android:thumb="#drawable/switch_selector"
and it works on Kitkat, but not on Lollipop.
I've found already that on Lollipop you may have much more to work.
Just take a look here: How to have a Lollipop switch button
So try to find your desired additional library like this above and let me know how it works ;-)
EDIT: To get API version use this:
Build.VERSION.RELEASE;
That will give you the actual numbers of your version; aka 2.3.3 or
2.2. The problem with using Build.VERSION.SDK_INT is if you have a rooted phone or custom rom, you could have a none standard OS (aka my
android is running 2.3.5) and that will return a null when using
Build.VERSION.SDK_INT so Build.VERSION.RELEASE will work no matter
what!
To use it, you could just do this;
String androidOS = Build.VERSION.RELEASE;
From: Retrieving Android API version programmatically
So i currently have a low-end Samsung Galaxy Pocket smartphone which uses the factory version of Android 2.3. When i test my apps in this device, it uses the gingerbread theme which is ugly. Android 4.2 UI is very nice and cool. So I want to know how to use the theme of Android 4.2 when im using lower versions of android. Here are some comparisons:
If you want to use the holo theme, you can use this library: HoloEverywhere. Alternatively, you can also create you're own theme.
Im distributing a mobile Android app that i have developed.
The popularity of Android 2.3.3 (API 10, 33% users) convinced me to develop the APK with the Minimum Android API setted to 10.
The problem is this: My app is tablet-friendly, but android tablets requires Min API to 11.
This setting will cut out a lot of phone users.
So what is the solution?
Make another APK for tablets?
Or there is a way to have both?
Thank you all.
Sure it is.
If you use supported libraries: http://developer.android.com/tools/support-library/index.html
And then create your App out of Fragments - then you can make an App for 2.3.3 with it's own Tablet layout.
http://developer.android.com/guide/components/fragments.html
I created an Android application. I tried this on differnet device and I have different layout in any Activity of my app. My Project Build Target is 2.3.3.
The two devices I used are:
Samsung Galaxy S2 - Android 2.3.6
HTC Desire - Android 2.3.5
For example the main Activity produces this layout in my Samsung:
and this in my HTC:
Why the two layout are so different?
This is because before Google introduced holo in Ice Cream Sandwich, manufacturers had a free hand in deciding how their devices' version of Android would look. Because of this, they could theme it to whatever they want.
I'm pretty sure that your app hasn't defined its own theme, and this is why you're getting such radically different looks on different devices.
To fix it, simply create your own theme and apply it to your activities.
This document can help you with styling your app.
You can use ActionBarSherlock with the Holo theme and Action Bar on older android versions (under 3.0).