Android 布局练习

简介: 要求:使用多种布局完成以下练习。 1.要求效果                                                                                                             完成效果 代码: <?xml version="1.0" encoding="utf-8"?>&lt

要求:使用多种布局完成以下练习。

1.要求效果                                                                                                             完成效果

代码:

<?xml version="1.0" encoding="utf-8"?>
<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="com.example.administrator.myapplication.zuoye728_1Activity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#beb0b0"
        android:id="@+id/ll1"
        >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="请登录"
            android:textSize="20sp"
            android:gravity="center"
            android:layout_marginTop="20dp"
            android:layout_marginBottom="20dp"
            />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ll1"
        android:orientation="vertical"
        android:id="@+id/ll2"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:clickable="true"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/xiaoxi"
                android:background="@drawable/zuoye728_1"
                android:layout_gravity="center"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="  消息平台"
                android:textColor="@color/test_bg"
                android:textSize="30sp"
                />
        </LinearLayout>
<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#beb0b0"
    >
</View>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ll2"
        android:orientation="vertical"
        android:id="@+id/ll3"
        android:clickable="true"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/huodong"
                android:layout_gravity="center"
                android:background="@drawable/zuoye728_2"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="  校园活动"
                android:textColor="@color/test_bg"
                android:textSize="30sp"
                />
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#beb0b0"
            >
        </View>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ll3"
        android:orientation="vertical"
        android:id="@+id/ll4"
        android:clickable="true"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/sixiang"
                android:layout_gravity="center"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="  思想引领"
                android:textColor="@color/test_bg"
                android:textSize="30sp"
                />
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#beb0b0"
            >
        </View>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ll4"
        android:orientation="vertical"
        android:id="@+id/ll5"
        android:clickable="true"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/jiuye"
                android:layout_gravity="center"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="  就业招聘"
                android:textColor="@color/test_bg"
                android:textSize="30sp"
                />
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#beb0b0"
            >
        </View>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ll5"
        android:orientation="vertical"
        android:id="@+id/ll6"
        android:clickable="true"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/kaoyan"
                android:layout_gravity="center"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="  考研出国"
                android:textColor="@color/test_bg"
                android:textSize="30sp"
                />
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#beb0b0"
            >
        </View>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ll6"
        android:orientation="vertical"
        android:id="@+id/ll7"
        android:clickable="true"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/b"
                android:layout_gravity="center"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="  便利工具"
                android:textColor="@color/test_bg"
                android:textSize="30sp"
                />
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>
2.完成下图三个布局。

作业1实际效果:


代码1:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/ic_launcher"
            android:layout_marginTop="20dp"
            />
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="热门评论"
                android:textColor="#ff0000"
                android:textSize="20sp"
                android:id="@+id/tv1"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="HighSmile山人"
                android:textSize="20sp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="丹麦治安一直都很好,这种事情估计可以
                轰动他们全国了"
                android:textColor=""
                />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:background="#d1c8c8"
                >
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@mipmap/ic_launcher"
                    />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="丹麦连发2起枪击案致16                    尚不清楚是否相关"
                    android:textColor=""
                    android:layout_gravity="center"
                    />
            </LinearLayout>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                >
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="5小时前"
                    android:layout_marginTop="10dp"
                    />
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@mipmap/dianzan"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="90dp"
                    />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="200"
                    android:layout_marginTop="10dp"
                    />
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@mipmap/pinglun"
                    android:layout_marginTop="6dp"
                    android:layout_marginLeft="10dp"
                    />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="1"
                    android:layout_marginTop="10dp"
                    />
            </LinearLayout>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="查看1条评论"
                android:textColor="#3a05e9"
                android:background="#d1c8c8"
                />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
作业2实际效果:


代码2:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#f1eaea"
        >
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"

                >
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:text="春晚五彩:沈腾小品还在"
                        android:textColor=""
                        android:textSize="20sp"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="修改"
                        android:textColor=""
                        android:textSize="20sp"
                        />
                </LinearLayout>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp"
                    android:text="新浪娱乐  评论  220"
                    />
            </LinearLayout>
        </LinearLayout>
        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:src="@mipmap/ic_launcher"
            android:layout_marginLeft="40dp"
            />
    </LinearLayout>
</LinearLayout>
作业3实际效果:

目录
相关文章
|
8月前
|
XML 前端开发 Android开发
Android XML 布局基础(四)内外边距(margin、padding)
Android XML 布局基础(四)内外边距(margin、padding)
168 0
|
8月前
|
编解码 Android开发
Android 常用布局单位区别(dp、sp、px、pt、in、mm)
Android 常用布局单位区别(dp、sp、px、pt、in、mm)
296 0
|
4月前
|
Android开发
Android Studio入门之常用布局的讲解以及实战(附源码 超详细必看)(包括线性布局、权重布局、相对布局、网格布局、滚动视图 )
Android Studio入门之常用布局的讲解以及实战(附源码 超详细必看)(包括线性布局、权重布局、相对布局、网格布局、滚动视图 )
121 0
|
4月前
|
Android开发 容器
Android开发,学习LinearLayout布局
Android开发,学习LinearLayout布局
38 0
|
4月前
|
XML Java Android开发
Android Studio App开发之循环试图RecyclerView,布局管理器LayoutManager、动态更新循环视图讲解及实战(附源码)
Android Studio App开发之循环试图RecyclerView,布局管理器LayoutManager、动态更新循环视图讲解及实战(附源码)
36 0
|
4月前
|
XML Java Android开发
Android Studio App开发中工具栏Toolbar、溢出菜单OverflowMenu、标签布局TabLayout的讲解及实战(实现京东App的标签导航栏,附源码)
Android Studio App开发中工具栏Toolbar、溢出菜单OverflowMenu、标签布局TabLayout的讲解及实战(实现京东App的标签导航栏,附源码)
58 0
|
4月前
|
Android开发 容器
Android开发第二次课 布局方式
Android开发第二次课 布局方式
23 0
|
6月前
|
XML 前端开发 Android开发
android 前端常用布局文件升级总结(一)
android 前端常用布局文件升级总结(一)
|
8月前
|
Android开发
Android 使用DataBinding时 将布局页面转换为数据绑定布局(Convert to data binding layout) 不出现提示解决办法
Android 使用DataBinding时 将布局页面转换为数据绑定布局(Convert to data binding layout) 不出现提示解决办法
90 0
|
8月前
|
Android开发
Android 实现布局的缩小和再放大动画(使用scale动画效果进行实现)
Android 实现布局的缩小和再放大动画(使用scale动画效果进行实现)
577 0