在Android系统中,自带的样式和主题都可以直接拿来用,设置样式只需要通过代码style=“?android:attr/...”即可,设置主题只需要通过代码android:theme="android:style/..."即可。
主题是在AndroidManifest.xml文件中添加的,代码:
<application
android:allowBackcup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="cn.itcast.style.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>
</application>