最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

TextInputLayout輸入框控件的懸浮標(biāo)簽

 更新時(shí)間:2017年12月04日 10:38:06   作者:ZhengJiaoCsdn  
這篇文章主要為大家詳細(xì)介紹了TextInputLayout輸入框控件的懸浮標(biāo)簽,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了TextInputLayout輸入框懸浮標(biāo)簽的具體代碼,供大家參考,具體內(nèi)容如下

TextInputLayout也是5.0以后的效果,想要使用同樣需要在build中配置:

dependencies { 
 compile 'com.android.support:design:23.3.0' 
} 

TextInputLayout可以用來(lái)顯示一個(gè)提示錯(cuò)誤信息,把Hint放到EditText左上方等效果的一個(gè)布局;
如果項(xiàng)目中有這類的需求,使用TextInputLayout實(shí)現(xiàn)起來(lái)非常方便;
使用方法也比較簡(jiǎn)單,直接用TextInputLayout包裹EditText即可:

<android.support.design.widget.TextInputLayout 
 android:id="@+id/til_user" 
 android:layout_width="match_parent" 
 android:layout_height="wrap_content" 
 android:layout_marginTop="20dp" 
 android:layout_marginLeft="20dp" 
 android:layout_marginRight="20dp"> 
 <EditText 
  android:id="@+id/et_user" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" 
  android:hint="請(qǐng)輸入用戶名"/> 
 </android.support.design.widget.TextInputLayout> 

但是默認(rèn)情況下,當(dāng)你輸入文本的時(shí)候TextInputLayout只會(huì)將Hint移動(dòng)到左上方,不會(huì)有錯(cuò)誤提示,錯(cuò)誤提示需要我們手動(dòng)設(shè)置:

etUser= (EditText) findViewById(R.id.et_user); 
 tilUser= (TextInputLayout) findViewById(R.id.til_user); 
 
 //添加文本變化監(jiān)聽 
 etUser.addTextChangedListener(new TextWatcher() { 
  @Override 
  //輸入文本之前調(diào)用 
  public void beforeTextChanged(CharSequence s, int start, int count, int after) { 
  } 
 
  @Override 
  //正在輸入的時(shí)候調(diào)用 
  public void onTextChanged(CharSequence s, int start, int before, int count) { 
  if(s.length()>6){ 
   //打開TextInputLayout異常提示 
   tilUser.setErrorEnabled(true); 
   //設(shè)置TextInputLayout異常提示信息 
   tilUser.setError("賬號(hào)最大長(zhǎng)度為6"); 
  }else { 
   //關(guān)閉TextInputLayout異常提示 
   tilUser.setErrorEnabled(false); 
  } 
  } 
 
  @Override 
  //輸入以后調(diào)用 
  public void afterTextChanged(Editable s) { 
  } 
 }); 

點(diǎn)擊打開鏈接免費(fèi)下載源碼

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

旬阳县| 邮箱| 海南省| 垣曲县| 木兰县| 古交市| 柳林县| 石柱| 林西县| 布尔津县| 静安区| 柳河县| 香河县| 纳雍县| 蒙山县| 扶余县| 江华| 马尔康县| 陆良县| 清流县| 成安县| 竹山县| 平安县| 枝江市| 英超| 界首市| 堆龙德庆县| 广河县| 揭西县| 开鲁县| 衡东县| 商洛市| 蕲春县| 从化市| 布尔津县| 社会| 阿巴嘎旗| 方城县| 那坡县| 井研县| 屏东县|