EditText:文本框编辑的浮动提示

这篇博客介绍了如何在Android中实现EditText的浮动提示功能,提供了两种方法:直接添加库到Android Studio和分析源码自定义。通过添加依赖和修改相关属性,可以轻松定制悬浮文本内容。文章还附带了源码解析和示例代码。
摘要由CSDN通过智能技术生成

最近在学习中用到了;浮动提示在EditText上的功能; 找了一圈;发现了 一个好用的 效果…..在这里记录下;
简单的实现浮动标签EditText:Android视图使用EditText之上,并提示EditText时填充文本。
参考项目地址:https://github.com/wrapp/floatlabelededittext

先看个人测试的效果:
这里写图片描述

下面直接使用方式:

方法一:直接添加库到AndoridStudio 中:

在app–>build.gradle 的 dependencies中直接添加:

dependencies {
  //--部分略
    //TJ:添加应用库-----
    //TJ:EditText:文本框编辑的浮动提示
    compile 'com.wrapp.floatlabelededittext:library:0.0.6'
}

然后 Sync Now…后 即可使用了 。 简单粗暴。
然后在要使用的地方:添加如下类似的操作代码即可:
完整的一个布局内容如:个人添加了四个选项功能

<?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:float="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"
   >


    <com.wrapp.floatlabelededittext.FloatLabeledEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:fletPaddingLeft="120dp"

        >

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:hint="This is a test" />
    </com.wrapp.floatlabelededittext.FloatLabeledEditText>

    <!-- add some padding -->
    <com.wrapp.floatlabelededittext.FloatLabeledEditText
        android:id="@+id/floatEdit2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        float:fletPadding="10dp"

        >

        <EditText
            android:id="@+id/edit2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Username" />
    </com.wrapp.floatlabelededittext.FloatLabeledEditText>

    <!-- password input -->
    <com.wrapp.floatlabelededittext.FloatLabeledEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        float:fletPaddingBottom="10dp"
        float:fletTextAppearance="@style/floatlabelededittext">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password" />
    </com.wrapp.floatlabelededittext.FloatLabeledEditText>

    <!-- change color of hint text-->
    <com.wrapp.floatlabelededittext.FloatLabeledEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        float:fletPaddingBottom="10dp"
        float:fletTextAppearance="@style/floatlabelededittext"

        >

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="PassWord Again"

            
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值