styleandroid
① Android TextView怎麼引用Style
1 首先需要在res/values目錄下創建一個styles.xml的文件
<TextView
style="@style/top_recommend_vod_title_style"/>
② Android系統自帶樣式Theme總結
本文從網上復制,給自己做筆記的,摘自: http://blog.csdn.net/hongya1109110121/article/details/11985545
Android系統自帶樣式(@android:style/) (轉)
1 android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
布局頁面最上面 不會顯示 android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。
2 android:theme="@style/AppTheme"
布局頁面最上面 顯示 android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。
其他
在數嫌並AndroidManifest.xml文件的activity中配置
1、android:theme="@android:style/Theme"
默認狀態,即如果theme這里不填任何屬性的時候,默認為Theme
2、android:theme="@android:style/Theme.NoDisplay"
任何都不顯示。比較適用於只是運行了activity,但未顯示任何東西
3、android:theme="@android:style/Theme.NoTitleBar「
背景主題的沒有標題欄者岩的樣式,默認如果沒有設置的話,顯示黑背景
4、android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
背景主題的沒有標題欄且全屏的樣式,默認為黑背景
5、android:theme="@android:style/Theme.Black"
默認狀態下黑背景
6、android:theme="@android:style/Theme.Black.NoTitleBar"
黑背景主題的沒有標題欄的樣式
7、android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
黑背景主題的沒有標題欄且全屏的樣式
8、薯跡android:theme="@android:style/Theme.Light"
默認狀態下亮背景,與上述黑背景Theme.Black相反
9、android:theme="@android:style/Theme.Light.NoTitleBar"
亮背景主題的沒有標題欄的樣式,與Theme.Black.NoTitleBar相反
10、android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
亮背景主題的沒有標題欄且全屏顯示的樣式,與Theme.Black.NoTitleBa.Fullscreenr相反
11、android:theme="@android:style/Theme.Dialog"
對話框樣式 將整個activity變成對話框樣式出現
12、android:theme="@android:style/Theme.InputMethod"
Window animations that are applied to input method overlay windows
13、android:theme="@android:style/ Theme.Panel"
刪除掉所有多餘的窗口裝飾,在一個空的矩形框中填充內容,作用范圍相當於把dialog中的所有元素全部去掉,只是一個空的矩形框,且此為默認的樣式
14、android:theme="@android:style/ Theme.Light.Panel"
刪除掉所有多餘的窗口裝飾,在一個空的矩形框中填充內容,作用范圍相當於把dialog中的所有元素全部去掉,只是一個空的矩形框,且默認是light的樣式
15、android:theme="@android:style/Theme.Wallpaper"
使用牆紙做主題,默認狀態。
16、android:theme="@android:style/ Theme.WallpaperSettings"
使用牆紙做主題,默認是使用將上一個界面調暗之後作為主題
17、android:theme="@android:style/ Theme.Light.WallpaperSettings"
使用牆紙做主題,默認Light狀態
18、android:theme="@android:style/Theme.Wallpaper.NoTitleBar"
使用牆紙做主題,且沒有標題欄
19、android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
使用牆紙做主題,且沒有標題欄,且全屏顯示
20、android:theme="@android:style/Theme.Translucent"
半透明狀態下的背景,將運行此activity之前的屏幕作為半透明狀態作為此activity運行時的樣式。
21、android:theme="@android:style/Theme.Translucent.NoTitleBar"
半透明狀態下沒有標題欄的背景,將運行此activity之前的屏幕作為半透明狀態作為此activity運行時的樣式。
22、android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
半透明狀態下沒有標題欄且全屏的背景,將運行此activity之前的屏幕作為半透明狀態作為此activity運行時的樣式。
摘自: http://blog.csdn.net/hongya1109110121/article/details/11985545
③ 為什麼 Android 改變標題欄style 之後 主體都變成黑色了
因為你改了style所以都變成默認的了 要把背景也設置style
④ android中怎麼創建style
自定義樣式方法,可以直接通過定義xml文件來實現不同的樣式:
只需要修改button_style文件,同樣三種狀態分開定義:
Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient android:startColor="#0d76e1" android:endColor="#0d76e1"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<gradient android:startColor="#ffc2b7" android:endColor="#ffc2b7"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="州源伏2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient android:startColor="#000000" android:endColor="#ffffff"
android:angle="180" />
<stroke android:width="1dip" android:color="#f403c9"冊攜 />
<corners android:radius="5dip" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</裂做shape>
</item>
</selector>
gradient 主體漸變 startColor開始顏色,endColor結束顏色 ,angle開始漸變的角度(值只能為90的倍數,0時為左到右漸變,90時為下到上漸變,依次逆時針類推)
stroke 邊框 width 邊框寬度,color 邊框顏色
corners 圓角 radius 半徑,0為直角
padding text值的相對位置