当前位置:操作系统 > 安卓/Android >>

界面布局:线性布局LinearLayout

布局文件:res/layout/activity_my.xml

[html]  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/LinearLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    tools:context=".MyActivity" > 
 
    <Button 
        android:id="@+id/button1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="@string/wo" 
        android:textColorHint="@color/calamus" /> 
 
    <Button 
        android:id="@+id/button2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="@string/shi" /> 
 
    <Button 
        android:id="@+id/button3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="@string/hao" 
        android:textColor="@color/calamus" /> 
 
    <Button 
        android:id="@+id/button4" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="@string/ren" /> 
 
</LinearLayout> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    tools:context=".MyActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/wo"
        android:textColorHint="@color/calamus" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/shi" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/hao"
        android:textColor="@color/calamus" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/ren" />

</LinearLayout>

资源文件:res/values/strings.xml

 

[html] view plaincopyprint?<?xml version="1.0" encoding="utf-8"?> 
<resources> 
 
    <string name="app_name">Linear</string> 
    <string name="action_settings">Settings</string> 
    <string name="wo">我</string> 
    <string name="shi">是</string> 
    <string name="hao">好</string> 
    <string name="ren">人</string> 
 
</resources> 

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Linear</string>
    <string name="action_settings">Settings</string>
    <string name="wo">我</string>
    <string name="shi">是</string>
    <string name="hao">好</string>
    <string name="ren">人</string>

</resources>

资源文件:res/values/styles.xml

[html] view plaincopyprint?<resources> 
 
    <!-- 
        Base application theme, dependent on API level. This theme is replaced 
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
    --> 
    <style name="AppBaseTheme" parent="android:Theme.Light"> 
        <!-- 
            Theme customizations available in newer API levels can go in 
            res/values-vXX/styles.xml, while customizations related to 
补充:移动开发 , Android ,

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,