Reputation: 1208
I am looking for a way to get different UI design for different API's. Google search gave me a link:http://developer.android.com/guide/google/play/publishing/multiple-apks.html#CreatingApks
In this link it states it is better to create different Apk's for different API and play store will take care of choosing the best one for the phone.
Is this the only method or is there any easy way?
Upvotes: 2
Views: 632
Reputation: 5980
Try not to use different APKs if at all possible; it creates a mess.
To use a specific layout for API 14, for example, use the folder /res/layout-v14
instead of /res/layout
. /res/layout-v8
for API 8, and so on…
Android will take resources from the folder that most closely matches it. The folders act as sort of a requirement. So, if you have API 15 and no layout-v15
folder, it will take it from layout-v14
. If you have layout-v14
and layout-v8
, if it's using API 10, it will use layout-v8
.
Upvotes: 1
Reputation: 16330
Well thats possible if you are ready to write more code,
One thing you can do if you want it to achieve different API levels with different UI is to detect API level runtime by using this constant: android.os.Build.VERSION.SDK_INT
. It returns one of these values.
Now according to this version you can have different layout xml
to be set as contentView of your activity.
Note : This has more maintenance hazard. In case you want to add/remove any UI element you have to modify all of your layout XMLs in your application.
Upvotes: 1
Reputation: 4042
It's not necessary to build multiple APKs to achieve this.
Look into the links at: http://developer.android.com/training/multiscreen/index.html.
Upvotes: 1