国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android自定義Style實(shí)現(xiàn)方法

2020-04-11 12:15:21
字體:
供稿:網(wǎng)友

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  m.survivalescaperooms.com
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main); 
    } 


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 荔浦县| 新乐市| 垣曲县| 汕头市| 高雄县| 马尔康县| 晋宁县| 治县。| 汉川市| 江达县| 美姑县| 天气| 江川县| 建德市| 全椒县| 湾仔区| 万山特区| 温州市| 夏邑县| 德格县| 长沙市| 依安县| 禹城市| 江孜县| 夏邑县| 同江市| 林周县| 无为县| 吉木乃县| 塔城市| 乳山市| 夏河县| 军事| 古蔺县| 东港市| 岐山县| 珠海市| 惠水县| 阿克陶县| 隆昌县| 东平县|