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

首頁 > 系統 > Android > 正文

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

2019-10-23 19:45:56
字體:
來源:轉載
供稿:網友

 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) {      }    });

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


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丹东市| 萝北县| 虹口区| 云南省| 邵武市| 抚松县| 百色市| 渝中区| 家居| 曲阜市| 郁南县| 绥化市| 永嘉县| 云霄县| 汉中市| 灵璧县| 广西| 教育| 杭锦旗| 卢氏县| 莎车县| 大冶市| 仙居县| 慈溪市| 辰溪县| 个旧市| 山阳县| 崇信县| 扎囊县| 恩平市| 随州市| 遂宁市| 横峰县| 嘉祥县| 怀柔区| 浮梁县| 波密县| 江门市| 上杭县| 阆中市| 德庆县|