Android 布局练习

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

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实际效果:

时间: 2024-08-25 23:47:03

Android 布局练习的相关文章

Android 布局学习之——Layout(布局)详解二(常见布局和布局参数)

  [Android布局学习系列]   1.Android 布局学习之--Layout(布局)详解一   2.Android 布局学习之--Layout(布局)详解二(常见布局和布局参数)   3.Android 布局学习之--LinearLayout的layout_weight属性   4.Android 布局学习之--LinearLayout属性baselineAligned的作用及baseline      Layout Parameters(布局参数):            在XML文

在android布局中测试能自动化点击按钮吗?

问题描述 在android布局中测试能自动化点击按钮吗? 我想测试程序的功能,想自动化大多数的用户交互.其中一个是按钮(一个需要用户交互的地方). 是否有可能自动化?是否违背安全呢? 解决方案 给你推荐一个文档,关于简单的Android自动化UI测试.Automated Unit Testing the Android UI 还有button.performClick();

Android布局优化

categories: Android 在Android开发中,我们常用的布局方式主要有LinearLayout.RelativeLayout.FrameLayout等,通过这 些布局我们可以实现各种各样的界面.与此同时,如何正确.高效的使用这些布局方式来组织UI控件,是我们 构建优秀Android App的主要前提之一.本篇内容就主要围绕Android布局优化来讨论在日常开发中我们使用常 用布局需要注意的一些方面,同时介绍一款SDK自带的UI性能检测工具HierarchyViewer. 布局原

Android 布局(Layout)指南

Android 布局(Layout)指南 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. Android 官方文档 布局 相关资源链接汇总如下: android-sdk-macosx-4.4.2

控件-android 布局问题 aliginBottom

问题描述 android 布局问题 aliginBottom RelativeLayout 中 a控件高200 ,b 控件alignbottom a,b控件的高度无法超过a 解决方案 没人能结局呢 换个方式 解决方案二: 你设置b的高度大于200不行吗 解决方案三: 可以设置一下,margin_bottom为 负值试一下...

android布局加载imagebutton问题详细求解

问题描述 android布局加载imagebutton问题详细求解 android布局中ImageButton怎么设置图片底色为透明,只保留图片上的画面. 解决方案 设置背景为透明色啊,background 解决方案二: background="#0000000" 解决方案三: android:background="#00000000" 一共8个"0" 解决方案四: android:id="@+id/button" andr

服务器-Android 布局错乱线现布局

问题描述 Android 布局错乱线现布局 从服务器获取数据后解析然后显示就这样了 解决方案 是没有做适配的原因吗,还是写布局的时候文本超出了手机屏幕的宽度,应该注意文本放置时的长度 解决方案二: android的布局! 解决方案三: 你把你item的布局贴出来看看.. 解决方案四: ok已经解决了 呗挤出去了 谢谢你们的答案

android布局配置问题关于webview

问题描述 android布局配置问题关于webview 我需要一个布局,就是一个界面整个是一个webview,然后读取本地的xml文件.这些都实现了,但是读取文件显示的时候,不能显示全部的,还剩两个边边没显示出来. 如何解决这个问题

【转】Android布局优化之ViewStub

ViewStub是Android布局优化中一个很不错的标签/控件,直接继承自View.虽然Android开发人员基本上都听说过,但是真正用的可能不多. ViewStub可以理解成一个非常轻量级的View,与其他的控件一样,有着自己的属性及特定的方法.当ViewStub使用在布局文件中时,当 程序inflate布局文件时,ViewStub本身也会被解析,且占据内存控件,但是与其他控件相比,主要区别体现在以下几点: 1.当布局文件inflate时,ViewStub控件虽然也占据内存,但是相相比于其他

android布局里如何实现类似html文字链接效果,我现在有的是两个Button,比较丑,有凸起感

问题描述 android布局里如何实现类似html文字链接效果,我现在有的是两个Button,比较丑,有凸起感 类似支付宝的,管理手势密码和其它用户登录这样的效果,可以点击链接到其它页面. 解决方案 使用html文本,然后让TextView的属性加下划线. Spanned ss = Html.fromHtml(CommentText); setMovementMethod(LinkMovementMethod.getInstance()); 解决方案二: to forlong401:不需要下划线