zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

[android] 安卓自定义样式和主题详解手机开发

Android安卓手机开发 详解 自定义 主题 样式
2023-06-13 09:20:13 时间

简单练习自定义样式和主题,样式是加在View上,主题是加在Application或者Activity上

styles.xml

 ?xml version="1.0" encoding="utf-8"? 

 resources xmlns:android="http://schemas.android.com/apk/res/android" 

 !-- 自定义样式 -- 

 style name="MyFont" 

 item name="android:textColor" #ff0000 /item 

 item name="android:textSize" 40sp /item 

 /style 

 style name="MyFontSon" parent="@style/MyFont" 

 item name="android:textSize" 30sp /item 

 /style 

 !-- 自定义主题 -- 

 style name="MyTheme" 

 item name=android:windowNoTitle true /item 

 item name="android:background" #ffffff /item 

 /style 

 /resources 

activity_main.xml

 ?xml version="1.0" encoding="utf-8"? 

 LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

 android:layout_width="match_parent" 

 android:layout_height="match_parent" 

 android:orientation="vertical" 

 TextView 

 android:layout_width="match_parent" 

 android:layout_height="wrap_content" 

 android:text="样式和主题" 

 TextView 

 android:layout_width="match_parent" 

 android:layout_height="wrap_content" 

 android:text="样式和主题" 

 /LinearLayout 

Manifest.xml

 application 

 android:allowBackup="true" 

 android:icon="@drawable/ic_launcher" 

 android:label="ss" 

 android:theme="@style/MyTheme" 

[android] 安卓自定义样式和主题详解手机开发

5376.html

app程序应用开发手机开发无线开发移动端开发