登录与注册

一、基本控件

1、标签控件(TextView)

  • 常用属性:text、textSize、textColor……

2、编辑框控件(EditText)

  • 常用属性:text、textSize、textColor、hint……

3、按钮控件(Button)

  • 常用属性:text、background、layout_width、layout_height……

二、知识点

  • 线性布局(LinearLayout)
  • 标签(TextView)
  • 编辑框(EditText)
  • 按钮(Button)
  • 安卓事件处理机制(Event Handling Mechanism)
  • 吐司(Toast)

三、创建安卓应用

在这里插入图片描述

四、添加背景图片

最好添加两张背景图片(一张用于登录与注册,第二张用于实现跳转页面)
在这里插入图片描述
将背景图片放在res/drawable目录

五、基于模板创建登录窗口

用于页面跳转实现的窗口
在这里插入图片描述

六、登录窗口布局资源文件

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center"
    android:orientation="vertical"
    android:background="@drawable/tt"
    tools:context=".Loginu">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="400dp"
        android:layout_weight="2"
        android:gravity="bottom"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/tv_user_login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/user_login"
            android:textColor="#9C27B0"
            android:textSize="35dp">
        </TextView>

    </LinearLayout>>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tvusername"
            android:layout_width="90dp"
            android:layout_height="60dp"
            android:ems="5"
            android:gravity="center"
            android:text="@string/username"
            android:textSize="20dp" />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:singleLine="true"
            android:id="@+id/edt_username"
            android:ems="10"
            android:hint="@string/input_username"

            android:inputType="textPersonName"
            />
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv_password"
            android:layout_width="90dp"
            android:layout_height="60dp"
            android:ems="10"
            android:gravity="center"
            android:text="@string/password"
            android:textSize="20dp" />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:id="@+id/edt_password"
            android:ems="10"
            android:hint="@string/input_password"
            android:singleLine="true"

            android:inputType="textPassword"
            />


    </LinearLayout>
    <LinearLayout
        android:layout_width="230dp"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:gravity="center_horizontal"

        android:orientation="horizontal">
        <Button

            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/custom_border"

            android:hint="登录"

            android:textColor="#130908"
            android:textSize="25dp"

            />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="25dp"
            android:background="@drawable/custom_border"
            android:hint="取消"

            android:textColor="#130908"
            android:textSize="25dp" />
    </LinearLayout>
</LinearLayout>

七、布局资源文件

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="@drawable/flow"
    android:orientation="vertical"
    android:padding="23dp"
    tools:context=".User">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tvusername"
        android:layout_marginTop="10dp"
        android:textColor="@color/colorAccent"
        android:textSize="25dp"/>

</LinearLayout>

八、字符串资源文件strings.xml

<resources>
    <string name="app_name"
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值