style和theme小用法

新建一个项目

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
	style="@style/submaxhis"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
	<!-- 第一个样式 -->
	<style name="maxhis"> <!-- 为样式定义一个全局唯一的名字-->
		<item name="android:textSize">18px</item> <!-- name属性的值为使用了该样式的View控件的属性 -->
		<item name="android:textColor">#0000CC</item>
	</style>
	<!-- 继承第一个样式 -->
	<style name="submaxhis" parent="@style/maxhis">
		<item name="android:textColor">#FF0000</item>
	</style>
	<!-- 第一个主题 -->
	<style name="maxhisTheme">
		<item name="android:windowNoTitle">true</item>  <!-- 没标题 --> 
		<item name="android:windowFullscreen">?android:windowNoTitle</item> <!-- 全屏显示 -->
	</style>

</resources>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.buke.demo"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name="SplashActivity"
                  android:label="@string/app_name"
                  android:theme="@style/maxhisTheme"
                  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值