国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android 開發實現EditText 光標居右顯示

2019-12-12 03:39:51
字體:
來源:轉載
供稿:網友

 Android 開發實現EditText 光標居右顯示

前言:

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

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

看布局你就明白是什么意思 了吧,代碼里面監聽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) {      }    });

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汽车| 离岛区| 上林县| 沧源| 奎屯市| 枣庄市| 阜阳市| 苍溪县| 且末县| 辰溪县| 加查县| 伊宁县| 龙川县| 新巴尔虎右旗| 新建县| 阜平县| 贺州市| 冕宁县| 海南省| 岚皋县| 广德县| 南岸区| 玉门市| 游戏| 贵德县| 通州区| 岗巴县| 扶沟县| 板桥市| 宝兴县| 金堂县| 石景山区| 霍城县| 鄂温| 博野县| 内黄县| 静宁县| 习水县| 宽甸| 三亚市| 六安市|