安卓开发-登录界面简单实现

实现效果:

实现步骤:

        创建3个输入框,1个按钮,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:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical"
    android:padding="20dp">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableStart="@mipmap/user" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableStart="@mipmap/pass"/>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <EditText
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:drawableStart="@mipmap/code"/>
        <ImageView
            android:layout_width="100dp"
            android:layout_height="50dp"
            android:layout_marginStart="20dp"
            android:src="@drawable/default_code"/>
    </LinearLayout>

    <Button
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:text="登录"
        android:layout_marginTop="50dp"
        android:layout_gravity="center"/>
</LinearLayout>

drawableStart 设置输入框的图标:显示在左侧

图片资源:

        以上传至文章

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值