EditText设置inputType=“textPassword“后hint 英文字体不对,而且不能换行

问题如题,我先上图看下遇到的问题

( ps: 我只想唱一句 : 你这该死的安卓~~ 让我心在痛 累在流!!!)

很明显字体偏大,字间隔很宽,关键还不会换行, 看一下我们需要的效果:

 看到只要把        

android:inputType="textPassword"

这一行干掉 一切就是我们想要的,但是产品不干了,必须要是密码输入框.不能明文

于是百度了很多方法 都是一种
 

passEdit.setTypeface(Typeface.DEFAULT);

亲测 无效.....🌩🌩🌩🌩,没有任何效果.

于是找到很多帖子 无非就是说设置android:inputType="textPassword"后 Typeface变成了Typeface.MONOSPACE,也就是要变回来DEFAULT就可以了,于是各种造....没造出来.

突然想到是不是先后顺序问题灵感来了,尝试果然OK,

贴出代码:

<EditText
    android:id="@+id/pass"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/transparent"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:hint="@string/qsz612wywszdmm16bad"
    android:imeOptions="actionNext"
    android:maxLength="50"
    android:paddingLeft="20dp"
    android:selectAllOnFocus="true"
    android:textColor="@color/white80"
    android:textColorHint="@color/white20"

    android:textSize="16sp" />

在java代码里面加入这一行:

        passEdit.setTypeface(Typeface.DEFAULT);
        passEdit.setTransformationMethod(new PasswordTransformationMethod());

看实际效果:  正常,并且Hint显示也字体正常切可以换行

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background"> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:text="会员昵称:" android:height="50px" /> <EditText android:id="@+id/nickname" android:hint="请输入会员昵称" android:layout_width="300px" android:layout_height="wrap_content" android:singleLine="true" /> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:text="输入密码:" android:height="50px" /> <EditText android:id="@+id/pwd" android:layout_width="300px" android:inputType="textPassword" android:layout_height="wrap_content" /> </TableRow> <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:text="确认密码:" android:height="50px" /> <EditText android:id="@+id/repwd" android:layout_width="300px" android:layout_height="wrap_content" android:inputType="textPassword" /> </TableRow> <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:text="E-mail:" android:height="50px" /> <EditText android:id="@+id/email" android:layout_width="300px" android:layout_height="wrap_content" android:inputType="textEmailAddress" /> </TableRow> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:text="注册" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:text="重置" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> </TableLayout>详细解释下这段代码的作用
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值