Android自定義Style實(shí)現(xiàn)方法
styles.xml如下:
[html]
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="testStyle">
<item name="android:textSize">30px</item>
<item name="android:textColor">#1110CC</item>
<item name="android:width">150dip</item>
<item name="android:height">150dip</item>
</style>
</resources>
main.xml如下:
[html]
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
style="@style/testStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
MainActivity如下:
[java]
package com.cn;
import android.os.Bundle;
import android.app.Activity;
/**
* Demo示例:
* 為控件設(shè)置自定義的Style
* 步驟:
* 1 在styles.xml文件中自定義一個(gè)style
* 在該style中可以預(yù)設(shè)各種參數(shù).如文字大小,顏色
* 寬,高等等屬性
* 2 在布局文件中為控件設(shè)置style屬性,如:style="@style/testStyle"
*/
public class MainActivity extends Activity {
@Override chabaoo.cn
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
- Android設(shè)置Activity背景為透明style的簡單方法(必看)
- Android Style.xml的應(yīng)用詳解及代碼實(shí)現(xiàn)
- Android開發(fā) -- UI界面之threme和style
- Android中自定義控件的declare-styleable屬性重用方案
- Android入門之Style與Theme用法實(shí)例解析
- Android 避免APP啟動(dòng)閃黑屏的解決辦法(Theme和Style)
- 基于android樣式與主題(style&theme)的詳解
- Android style的繼承方式 點(diǎn)(.)和parent詳解及實(shí)例
相關(guān)文章
webview添加參數(shù)與修改請求頭的user-agent實(shí)例
這篇文章主要介紹了webview添加參數(shù)與修改請求頭的user-agent實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-03-03Android總結(jié)之WebView與Javascript交互(互相調(diào)用)
本篇文章主要介紹了WebView與Javascript進(jìn)行數(shù)據(jù)交互,詳解的講訴了WebView與Javascript進(jìn)行數(shù)據(jù)交互的方法,有興趣的可以了解一下。2016-11-11Android的HTTP類庫Volley入門學(xué)習(xí)教程
這篇文章主要介紹了Android應(yīng)用開發(fā)框架Volley的入門學(xué)習(xí)教程,Volley適合于輕量級(jí)的通信功能開發(fā),善于處理JSON對(duì)象,需要的朋友可以參考下2016-02-02Android獲取系統(tǒng)儲(chǔ)存以及內(nèi)存信息的方法(二)
這篇文章主要為大家詳細(xì)介紹了Android獲取系統(tǒng)儲(chǔ)存以及內(nèi)存信息的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10Android5.0以上版本錄屏實(shí)現(xiàn)代碼(完整代碼)
這篇文章主要介紹了Android5.0以上版本錄屏實(shí)現(xiàn)代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2018-01-01Android自定義控件實(shí)現(xiàn)雷達(dá)圖效果
這篇文章主要為大家詳細(xì)介紹了Android自定義控件實(shí)現(xiàn)雷達(dá)圖效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-09-09Android實(shí)現(xiàn)動(dòng)態(tài)向Gallery中添加圖片及倒影與3D效果示例
這篇文章主要介紹了Android實(shí)現(xiàn)動(dòng)態(tài)向Gallery中添加圖片及倒影與3D效果的方法,涉及Android針對(duì)圖片的加載、顯示、翻轉(zhuǎn)、倒影等相關(guān)特效功能實(shí)現(xiàn)技巧2016-08-08