美文网首页Android Utils
Android UI 布局 <include />

Android UI 布局 <include />

作者: 几千里也 | 来源:发表于2015-04-16 11:37 被阅读416次

    activity_main.xml

    <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">
    
        <include
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginTop="30dp"
            layout ="@layout/header" />
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:weightSum="1">
            <Button android:text="@string/hello_world"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.5"
                android:layout_gravity="center_vertical" />
        </LinearLayout>
    
        <include layout ="@layout/footer" />
    
    </RelativeLayout>
    

    header.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:gravity="center"
        android:text= "@string/header"
        android:textSize="@dimen/abc_text_size_large_material">
    
    </TextView>
    

    footer.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom= "true"
        android:layout_marginBottom="30dp"
        android:gravity="center"
        android:text= "@string/footer"
        android:textSize="@dimen/abc_text_size_large_material">
    
    </TextView>
    
    图 1 图 2

    相关文章

      网友评论

        本文标题:Android UI 布局 <include />

        本文链接:https://www.haomeiwen.com/subject/tebsfttx.html