支持不同的安卓系统

来源:互联网 发布:ie8 数组 indexof 编辑:程序博客网 时间:2024/06/05 16:54

在AndroidManifest文件里面申明目标API和最小API。

<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />    ...</manifest>


为了使用不同的设备,需要了解app中用到的功能,例如判使用ActoinBar就需要api11及以上的系统。

private void setUpActionBar() {    // Make sure we're running on Honeycomb or higher to use ActionBar APIs    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {        ActionBar actionBar = getActionBar();        actionBar.setDisplayHomeAsUpEnabled(true);    }}

使用系统风格与主题:

让Activity像对话框一样展示

<activity android:theme="@android:style/Theme.Dialog">
设置背景

<activity android:theme="@android:style/Theme.Translucent">

自定义主题风格:在/res/calues/styles/xml:添加主题样式:

<activity android:theme="@style/CustomTheme">
让后再需要用到的地方申明,例如:

<application android:theme="@style/CustomTheme">


0 0
原创粉丝点击