Layout的编写

本文介绍了如何在Android Studio中创建新项目并完成Layout布局。从选择空项目开始,逐步讲解了在Activity_main.xml中修改,添加Activity_information.xml和Activity_login.xml文件,更新MainActivity和创建InformationActivity、LoginActivity。同时,还涉及到在res/drawable中添加shape XML文件circle_shape.xml、circle_stroke.xml及图片资源,最后通过Debug运行应用。
摘要由CSDN通过智能技术生成

标题:Layout项目的完成

  1. 使用 Android Studio 创建一个新项目, 选择如图所示在这里插入图片描述
  2. 选择一个空的页面然后一直Next
    3.一直选择next

4.在Layout的Activity_main.xml 里进行修改在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    tools:context=".MainActivity">

</androidx.constraintlayout.widget.ConstraintLayout>

5.添加 Activity_information.xml 在Layout中。

<?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=".LoginActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/default_icon"/>


    <TextView
        android:layout_width="match_parent"
        android:layout_height="30sp"
        android:text="用户名"
        android:textSize="20sp"
        android:gravity="center"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/name"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="姓名:"
            android:textSize="30sp" />

        <EditText
            android:id="@+id/et_realname"
            android:layout_width="250dp"
            android:layout_height="match_parent"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/group_sex"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="性别:"
            android:textSize="30sp"/>

        <RadioGroup
            android:id="@+id/sex"
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:orientation="horizontal">
            <RadioButton
                android:id="@+id/nan"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="男"
                android:textSize="20sp"
                android:checked="true"/>


            <RadioButton
                android:id="@+id/nv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="女"
                android:textSize="20sp"
                android:checked="true"/
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值