您的位置:首页 > 移动开发 > Android开发

Android使用系统样式及主题

2012-11-18 03:04 381 查看
主题一般是针对整个Activity而言的,样式是针对某个具体的控件而言的

1 在清单文件中使用系统主题,方式如下:
<activity android:name=".MainActivity"
android:theme="@android:style/Theme.Dialog"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
2 在代码中使用系统主题,方式如下:
this.setTheme(android.R.style.Theme);

3 某个控件设置风格,方式如下:
<Button
style="@android:style/ButtonBar"
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>


4 使用系统自带的style,方式如下:

<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />


重要参考资料:

http://blog.csdn.net/xiaomao5200/article/details/7497691
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: