FloatLabeledEditText实现另类输入框

今天,主要是看见朋友的软件的输入框,提示信息会自动向上弹,而不是消失,就问他要了控件,
写了一下效果还不错,这里和大家分享下。
这里主要是用到了 新控件FloatLabeledEditText

下面我就简单的说下用法首先添加依赖

 compile'com.wrapp.floatlabelededittext:library:0.0.6'

然后是应用了这里我给大家xml文件

<?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"
    xmlns:float="http://schemas.android.com/apk/res-auto"
    android:id="@+id/content_main"
    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">

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

    <!-- add some padding 添加了一些间距 -->
    <com.wrapp.floatlabelededittext.FloatLabeledEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        float:fletPadding="10dp">

        <EditText
            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">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:inputType="textPassword" />
    </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="Styled Hint"
            android:inputType="textPassword" />
    </com.wrapp.floatlabelededittext.FloatLabeledEditText>
</LinearLayout>

下面再给出一些用到的

 xmlns:float="http://schemas.android.com/apk/res-auto"

这个是最后一个变色的style

 <style name="floatlabelededittext">
        <item name="android:textColor">#FF0000</item>
    </style>

然后运行就可以了 是不是特别简单好用O(∩_∩)O哈哈~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值