`

ch017 Android 样式与主题

阅读更多

--------------------------------------------AndroidManifest.xml----------------------------------

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.ch17"

    android:versionCode="1"

    android:versionName="1.0" >

    <uses-sdk

        android:minSdkVersion="10"

        android:targetSdkVersion="15" />

    <application

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@style/AppTheme" >

        <activity

            android:name=".MainActivity"

            android:label="@string/title_activity_main" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>

</manifest>

--------------------------------------------layout activity_main.xml-----------------------------

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/LinearLayout1"

    

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

    <TextView android:text="@string/hello_world" style="@style/normal_style"/>

    <EditText style="@style/normal_style"/>

    <Button style="@style/normal_style"/>

</LinearLayout>

--------------------------------------------values styles.xml-------------------------------------

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 扩展系统样式 -->

    <style name="AppTheme" parent="android:Theme.Light">

        <item name="android:textSize">24dp</item>

    </style>

    <!-- 自定义样式 -->

    <style name="normal_style">

        <item name="android:layout_width">fill_parent</item>

        <item name="android:layout_height">wrap_content</item>

    </style>

</resources>

--------------------------------------------MainActivity.java--------------------------------------

package com.ch17;

import android.app.Activity;

import android.os.Bundle;

public class MainActivity extends Activity {

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

    }

}

--------------------------------------------效果----------------------------------------------------

<!--EndFragment-->
  • 大小: 93.1 KB
0
1
分享到:
评论
Global site tag (gtag.js) - Google Analytics