日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android 常用 style,Android中 Styles和Themes

發布時間:2025/4/5 Android 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 常用 style,Android中 Styles和Themes 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

部分內容摘自:

http://blog.csdn.net/woshishushangdezhu/article/details/4602597

1.什么是Style,什么是Theme?

1)

Style:是一個包含一種或者多種格式化屬性的集合,我們可以將其作為一個單位用在布局XML單個元素當中。

2)

Theme:是一個包含一種或者多種格式化屬性的集合,我們可以將其作為一個單位用在應用中所有的Activity當中或者應用中的某個Activity當 中。

2.?定義Styles和Themes資源

Styles和Themes都是資源,存放在res/values文件夾下。

對每一個Styles和Themes,給

1) 自定義一個style

在res/values/sytles.xml中添加自定義的style:

flagNoExtractUi|flagNoFullscreen

18sp

#EC9237

那如何應用這個style呢?

style="@style/EditTextStyle"

android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

android:gravity=”center_vertical|center_horizontal”

android:text=”moandroid”/>上面這個EditText的樣式,顯示輸入法的時候就不會全屏顯示而擋住輸入的內容。

2)自定義一個Theme

Theme依然在

定義Theme的一個例子

<?xml version=”1.0″ encoding=”UTF-8″?>

true

14sp

#FFFF0000

@ 表明我們應用的資源是前邊定義過的(或者在前一個項目中或者在Android 框架中)。

?表明我們引用的資源的值在當前的主題當中定義過。

在程序中使用Theme的方法

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setTheme(R.style.NewTheme);

setContentView(R.layout.main);

}

在AndroidManifest.xml中應用Theme

為了在當前所有的Activity當中使用Theme,可以打開AndroidManifest.xml 文件,編輯標簽,讓其包含android:theme屬性,值是一個主題的名字,例如:。

如果只是想讓程序當中的某個Activity擁有這個Theme,那么可以修改標簽。Android中提供了幾種內置的資源,有好幾種Theme你可以切換而不用自己寫。比如可以用對話框Theme來讓你的Activity看起來像一個對話框。在manifest中定義,例如:

如果喜歡一個Theme,但是想做一些輕微的改變,只需要將這個Theme添加為parent。Android SDK為我們提供了很多現成的Them。

3. 開發中常用的style屬性

@style/Button.Light

@style/CheckBox.Light

@style/GridView.Light

@style/ListView.Light

@style/TextView.Light

@style/Spinner.Light

@style/RadioButton.Light

@style/EditText.Light

@style/AutoCompleteTextView.Light

@style/ProgressBar.Light

@style/SpinnerDropDownItem.Light

@android:color/transparent

@drawable/scrollbar_horizontal

@drawable/scrollbar_vertical

@style/ProgressBar.Horizontal.Light

@null

true

@null

true

@null

@null

true

總結

以上是生活随笔為你收集整理的android 常用 style,Android中 Styles和Themes的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。