標題:
theme
[打印本頁]
作者:
tonyh
時間:
2018-7-21 16:07
標題:
theme
本帖最後由 tonyh 於 2018-7-21 17:40 編輯
style 的配置是針對元件,若要統一配置整頁(activity)或整個app的風格,則需要使用theme(主題)來控制。試著練習以「Theme Editor」調配出兩個不同風格的介面。
[attach]4496[/attach]
[attach]4497[/attach]
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.student.myapplication" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/MyTheme02" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
複製代碼
values/styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="MyTheme01" parent="@android:style/Theme.Holo">
<!-- Customize your theme here. -->
</style>
<style name="MyTheme02" parent="@android:style/Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorForeground">@color/foreground_material_light</item>
<item name="android:textColorPrimary">@color/primary_text_material_light</item>
<item name="android:colorPrimaryDark">@color/primary_dark_material_light</item>
<item name="android:colorPrimary">@color/primary_material_light</item>
<item name="android:colorAccent">@color/accent_material_light</item>
</style>
<style name="Style01">
<item name="android:background">#e20000</item>
<item name="android:textColor">#fff0f0</item>
<item name="android:textSize">30sp</item>
<item name="android:gravity">center</item>
</style>
<style name="Style02" parent="Style01">
<item name="android:background">#006de2</item>
<item name="android:textColor">#f0f6ff</item>
<item name="android:layout_marginTop">10dp</item>
</style>
</resources>
複製代碼
作者:
李允軒
時間:
2018-7-21 17:52
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.jerryli92.myapplication" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/MyTheme02" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
複製代碼
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="style01">
<item name="android:background">#db0000</item>
<item name="android:textSize">30sp</item>
<item name="android:textColor">#ffd0d0</item>
<item name="android:gravity">center</item>
</style>
<style name="style02" parent="style01">
<item name="android:background">#0012d7</item>
<item name="android:layout_marginTop">10dp</item>
</style>
<style name="MyTheme01" parent="@android:style/Theme.Material.NoActionBar.TranslucentDecor" >
<item name="android:colorPrimary">@color/primary_material_dark</item>
<item name="android:colorPrimaryDark">@color/primary_dark_material_dark</item>
<item name="android:colorBackground">@color/background_material_dark</item>
</style>
<style name="MyTheme02" parent="@android:style/Theme.Holo.Light.NoActionBar.Overscan" >
<item name="android:colorPrimary">@color/holo_light_primary</item>
<item name="android:colorPrimaryDark">@color/holo_light_primary_dark</item>
<item name="android:colorBackground">@color/background_holo_light</item>
<item name="android:colorForeground">@color/bright_foreground_holo_light</item>
<item name="android:navigationBarColor">@color/black</item>
<item name="android:statusBarColor">@color/black</item>
</style>
</resources>
複製代碼
[attach]4500[/attach]
[attach]4501[/attach]
作者:
林宇翔
時間:
2018-7-21 18:04
[attach]4502[/attach][attach]4503[/attach]
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2