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

Android 開發(fā)實現(xiàn)EditText 光標(biāo)居右顯示

 更新時間:2017年02月22日 11:50:18   作者:何東_hd  
這篇文章主要介紹了Android 開發(fā)實現(xiàn)EditText 光標(biāo)居右顯示的相關(guān)資料,需要的朋友可以參考下

 Android 開發(fā)實現(xiàn)EditText 光標(biāo)居右顯示

前言:

有些時候肯定會遇到這種奇葩的需求,光標(biāo)要靠右顯示,因為Android里面光標(biāo)默認(rèn)是靠左顯示的,那怎么實現(xiàn)呢,肯定有辦法的,這里提供一種實現(xiàn)方式,看布局

 <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
      android:id="@+id/tv"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginRight="6dp"
      android:background="@null"
      android:gravity="right|center_vertical"
      android:text="請輸入您想輸入的" />

    <EditText
      android:id="@+id/et"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="right|center_vertical" />
  </FrameLayout>

看布局你就明白是什么意思 了吧,代碼里面監(jiān)聽EditText輸入,讓TextView顯示隱藏就行了。

 et.addTextChangedListener(new TextWatcher() {
      @Override
      public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
      }

      @Override
      public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        if (TextUtils.isEmpty(charSequence)) {
          tv.setVisibility(View.VISIBLE);
        } else {
          tv.setVisibility(View.GONE);
        }
      }

      @Override
      public void afterTextChanged(Editable editable) {
      }
    });

 感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論

汤阴县| 衢州市| 康马县| 余姚市| 北辰区| 岑溪市| 闸北区| 南郑县| 乳山市| 奇台县| 沅江市| 富平县| 当涂县| 托里县| 唐河县| 个旧市| 大宁县| 潮州市| 苍溪县| 囊谦县| 寻甸| 集贤县| 噶尔县| 祁门县| 富顺县| 汉阴县| 且末县| 陵水| 上蔡县| 云和县| 沂南县| 南京市| 文昌市| 汉川市| 周宁县| 石首市| 五大连池市| 息烽县| 巫溪县| 平湖市| 湟源县|