Android樣式和主題
樣式:
定義元件樣式的時候有兩種定義方法:
1.直接在main.xml的元件中定義樣式
2.用style="@style/"引用values資料夾下的樣式檔案裡定義的樣式
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
style="@style/style1"
android:text="hahahaha1" />
<TextView
style="@style/style2"
android:text="hahahaha2" />
<TextView
style="@style/style2.style1"
android:text="hahahaha4" />
<!-- 最基本的樣式寫法,直接寫在元件裡,和html標籤中寫style屬性一個意思 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hahahaha3"
android:textSize="30sp"
android:textColor="#0000FF" />
</LinearLayout>
string,xml(也可以新建一個樣式的xml檔案,在裡邊定義樣式)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, MainActivity!</string>
<string name="app_name">TestStyle</string>
<style name="style1">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#FF0000</item>
<item name="android:textSize">50sp</item>
</style>
<!-- 樣式的繼承 -->
<style name="style2" parent="style1">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#00FF00</item>
</style>
<!-- 樣式的繼承另一種寫法 -->
<style name="style2.style1">
</style>
</resources>
主題:
主題就是清單檔案中的android:theme屬性,當這個屬性在application元件中就是做用於所有Activity,當這個屬性在某個Activity上,就表示對某個Activity有效。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxc.style"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<!-- android:theme也可以定義在application-->
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<!-- android:theme用來定義Activity樣式的 -->
<activity
android:theme="@android:style/Theme.Dialog"
android:name=".MainActivity"
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>
</manifest>
相關文章
- 淺談Android主題樣式Android
- typora 基本使用和漂亮的主題樣式
- Tkinter (41) 定製和建立 ttk 主題和樣式
- Avalonia 中的樣式和控制元件主題控制元件
- 【UniApp】-uni-app-修改元件主題和樣式APP元件
- flutter theme 主題樣式生成工具Flutter
- Flutter Theme應用主題共享顏色和字型樣式Flutter
- Flutter 樣式基礎之 Theme 主題Flutter
- oh-my-zsh 主題樣式列表
- CARDS主題 & 導航欄樣式修改
- 部落格園主題樣式更改總結
- android短視訊開發,自定義更改平臺主題以及狀態列樣式Android
- OpenWrt軟體包各主題樣式預覽
- 水果主題色創意logo效果Ps樣式Go
- 切換頁面主題樣式研究及less教程
- Android中Context樣式分析AndroidContext
- (S)CSS中實現主題樣式的4½種方式 [譯]CSS
- 關於前端主題切換的思考和現代前端樣式的解決方案落地前端
- 【Android】設定 LinearLayout 的樣式Android
- Android 樣式屬性的使用Android
- 繫結class樣式和style樣式
- Android夜間模式(多主題)探索Android模式
- Android開發之動態設定字型的樣式和粗細Android
- 樣式問題--記錄
- 雲主機和雲主機是不一樣的
- CSS 背景樣式和列表CSS
- uni-app全域性樣式和區域性樣式APP
- van-popup 樣式問題
- 怎樣解題|題2.4.27:三項式定理
- Android更換APP字型—TextView各種字型樣式AndroidAPPTextView
- 3-主題和佇列佇列
- 響應式WordPress STAR主題原始碼原始碼
- Android沉浸式狀態列還能這樣玩—教你玩出新花樣Android
- 怎樣解題|題4.3.12:多項式展開
- Android 沉浸式解析和輪子使用Android
- element UI前端樣式不生效問題UI前端
- element UI元件樣式重複問題UI元件
- 如何解決div樣式拉伸問題
- 外掛化實現Android多主題功能原理剖析Android