[Android Studio]通过设计一些简单的界面来理解常用的布局

0. 设计的几个布局的效果如下:

在这里插入图片描述

1.针对线性布局设计的登录界面

在这里插入图片描述
在这里插入图片描述)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/background"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户登录"
        android:textSize="40sp"
        android:textColor="#000000"
        android:textStyle="normal"
        android:layout_marginTop="100dp"
        android:layout_gravity="center"
         />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_gravity="center">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用户名:"
            android:textSize="20sp"
            android:textColor="#000000"/>
        <EditText
            android:id="@+id/edit_inputname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="请输入用户名"
            android:textSize="20sp"
            />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_gravity="center">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密码:"
            android:textSize="20sp"
            android:textColor="#000000"/>
        <EditText
            android:id="@+id/edit_inputpwd"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="请输入密码"
            android:inputType="textPassword"
            android:textSize="20sp"
            />
    </LinearLayout>
    <CheckBox
        android:id="@+id/check_remeber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="记住密码"
        android:textStyle="normal"
        android:layout_gravity="right"
        android:layout_margin="10dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_gravity="center">
        <Button
        android:id="@+id/button_yes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登录"
            android:textSize="30sp"
            android:textColor="#050505"
            android:layout_weight="1"/>
        <Button
            android:id="@+id/button_no"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="取消"
            android:textSize="30sp"
            android:textColor="#050505"
            android:layout_weight="1"/>
    </LinearLayout>
</LinearLayout>

2、针对相对布局设计的简单游戏界面

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

<?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"
    android:background="#ffffff"
    tools:context=".MainActivity">
    <ImageView
        android:id="@+id/Game"
        android:layout_width="wrap_content"
        android:layout_height="240dp"
        android:src="@drawable/game"
        android:layout_marginBottom="30dp"
        />

    <Button
        android:id="@+id/button_up"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_below="@+id/Game"
        android:layout_alignLeft="@+id/Blank"
        android:background="@drawable/up"/>
    <ImageView
        android:id="@+id/Blank"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_marginLeft="60dp"
        android:layout_below="@+id/button_up"
        android:src="@drawable/blank"
        />
    <Button
        android:id="@+id/button_down"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_below="@+id/Blank"
        android:layout_alignLeft="@+id/Blank"
        android:background="@drawable/down"/>

    <Button
        android:id="@+id/button_left"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_marginLeft="60dp"
        android:layout_toRightOf="@+id/Blank"
        android:layout_alignTop="@+id/Blank"
        android:layout_below="@+id/Game"
        android:background="@drawable/left"/>
    <ImageView
        android:id="@+id/Blank1"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_toRightOf="@+id/button_left"
        android:layout_alignTop="@+id/button_left"
        android:src="@drawable/blank"
        />
    <Button
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_toRightOf="@+id/Blank1"
        android:layout_alignTop="@+id/Blank1"
        android:background="@drawable/right"/>
    <Button
        android:id="@+id/button_start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="开始游戏"
        android:layout_below="@+id/button_down"
        android:layout_alignLeft="@+id/button_down"
        android:layout_marginTop="30dp"
        android:textSize="30sp"
        android:textColor="#050505"
        android:layout_weight="1"/>
    <Button
        android:id="@+id/button_end"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="退出游戏"
        android:layout_below="@+id/Blank1"
        android:layout_alignTop="@+id/button_start"
        android:layout_toRightOf="@+id/button_start"
        android:textSize="30sp"
        android:textColor="#050505"
        android:layout_weight="1"/>
</RelativeLayout>

3. 帧布局、线性布局设计后台界面

![在这里插入图片描述](https://img-blog.csdnimg.cn/20200324131732877.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0hvbmV5Y29tYl8x,size_16,color_FFFFFF,t_70)
在这里插入图片描述

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

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="@drawable/background">
        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:src="@drawable/icon"
            android:layout_gravity="center"
            android:layout_marginTop="-20dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="久醉"
            android:textSize="30sp"
            android:textColor="#ffffff"
            android:layout_gravity="center"
            android:layout_marginTop="40dp"/>
    </FrameLayout>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="个人中心"
        android:textSize="30sp"
        android:textStyle="normal"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"/>
        <View
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="#E91A1A"
        />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="设置"
            android:textSize="25sp"
            android:padding="10dp"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#C5C2C2"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="修改密码"
        android:textSize="25sp"
        android:padding="10dp"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#C5C2C2"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="作品详情"
        android:textSize="25sp"
        android:padding="10dp"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#C5C2C2"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="注销"
        android:textSize="25sp"
        android:padding="10dp"/>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#C5C2C2"
        />

</LinearLayout>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值