Android 中 EditText 的基本使用

本文介绍了Android中EditText的使用,包括常见的布局属性设置,如宽度、高度、提示文本等;自定义输入框样式,如背景形状、图标显示;以及如何添加文本监听事件,实现对输入内容的实时跟踪。通过实例展示了EditText在登录界面的应用,为Android开发提供基础参考。

Android 中 EditText 的基本使用

1. 常见属性

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:padding="15dp"
    tools:context=".EditTextActivity">

    <EditText
        android:id="@+id/et_1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginBottom="15dp"
        android:autofillHints=""
        android:hint="@string/username"
        android:inputType="text"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:textColor="@color/red"
        android:textSize="16sp" />

</RelativeLayout>

2. 自定义样式

在这里插入图片描述

照片放在指定路径下, 可以按照原有的招嫖改动比例大小.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:padding="15dp"
    tools:context=".EditTextActivity">

    <EditText
        
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值