Android自定義Style實現(xiàn)方法
更新時間:2013年06月05日 09:56:48 作者:
Android自定義Style實現(xiàn)方法,需要的朋友可以參考一下
styles.xml如下:
[html]
復(fù)制代碼 代碼如下:
<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]
復(fù)制代碼 代碼如下:
<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]
復(fù)制代碼 代碼如下:
package com.cn;
import android.os.Bundle;
import android.app.Activity;
/**
* Demo示例:
* 為控件設(shè)置自定義的Style
* 步驟:
* 1 在styles.xml文件中自定義一個style
* 在該style中可以預(yù)設(shè)各種參數(shù).如文字大小,顏色
* 寬,高等等屬性
* 2 在布局文件中為控件設(shè)置style屬性,如:style="@style/testStyle"
*/
public class MainActivity extends Activity {
@Override www.dbjr.com.cn
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
相關(guān)文章
webview添加參數(shù)與修改請求頭的user-agent實例
這篇文章主要介紹了webview添加參數(shù)與修改請求頭的user-agent實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03Android總結(jié)之WebView與Javascript交互(互相調(diào)用)
本篇文章主要介紹了WebView與Javascript進行數(shù)據(jù)交互,詳解的講訴了WebView與Javascript進行數(shù)據(jù)交互的方法,有興趣的可以了解一下。2016-11-11Android的HTTP類庫Volley入門學(xué)習(xí)教程
這篇文章主要介紹了Android應(yīng)用開發(fā)框架Volley的入門學(xué)習(xí)教程,Volley適合于輕量級的通信功能開發(fā),善于處理JSON對象,需要的朋友可以參考下2016-02-02Android獲取系統(tǒng)儲存以及內(nèi)存信息的方法(二)
這篇文章主要為大家詳細介紹了Android獲取系統(tǒng)儲存以及內(nèi)存信息的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10Android5.0以上版本錄屏實現(xiàn)代碼(完整代碼)
這篇文章主要介紹了Android5.0以上版本錄屏實現(xiàn)代碼,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2018-01-01Android實現(xiàn)動態(tài)向Gallery中添加圖片及倒影與3D效果示例
這篇文章主要介紹了Android實現(xiàn)動態(tài)向Gallery中添加圖片及倒影與3D效果的方法,涉及Android針對圖片的加載、顯示、翻轉(zhuǎn)、倒影等相關(guān)特效功能實現(xiàn)技巧2016-08-08