How set ICS theme for application with minSDK 7?

懵懂的女人 提交于 2019-12-21 05:56:25

问题


could anybody tell me how can I set a theme for my application which will change when version of Android will change. For example if anybody will use my app on Android 2.1 theme will look like this: http://daily-money.googlecode.com/svn/wiki/img/prefs.png

But if anybody will use my app on for example Android 4.0.3 theme will look like this: http://img.tapatalk.com/dcff019c-27ba-1e1a.jpg I have used minSDK 7.

Thank you.


回答1:


What you want is detailed in on this page: http://android-developers.blogspot.com/2012/01/holo-everywhere.html

In the section titled "Defaults for Older Apps"

You setup 2 theme files, one in the values directory and one in the values-v11 directory. Then you reference that theme file in the Manifest. As outlined in the page I linked above. You need ALL THREE blocks of XML outlined on that page under the "Using Holo while supporting Android 2.x" section.




回答2:


first get the version of android running on the device :

if (android.os.Build.VERSION.SDK_INT >= 11) {

....

en after you can use setTheme(..) before calling setContentView(...)and super.oncreate() and it should work fine




回答3:


@letroll, what parameter do you pass to setTheme? Does it require increasing min sdk to 13 to make the SDK available?



来源:https://stackoverflow.com/questions/8732988/how-set-ics-theme-for-application-with-minsdk-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!