久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android:TextView 自動截斷并替換字符串的最后 3 個字

Android: TextView automatically truncate and replace last 3 char of String(Android:TextView 自動截斷并替換字符串的最后 3 個字符)
本文介紹了Android:TextView 自動截斷并替換字符串的最后 3 個字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如果 StringTextView 的寬度長,它會自動換行到下一行.我可以通過使用 android:singleLine(已棄用)或設置 android:inputType="text" 來避免這種情況.我現在需要的是用..."替換我的 String 的最后 3 個字符.由于我沒有使用等寬字體,因此這將始終根據我的 String 中使用的字母而有所不同.所以我想知道在 TextView 中獲取字符串的最后 3 個字符并替換它們的最佳方法是什么.也許Android框架中已經實現了一些東西,因為這一定是一個常見的問題.

If a String is longer than the TextView's width it automatically wraps onto the next line. I can avoid this by using android:singleLine (deprecated) or by setting android:inputType="text". What I need now is something that replaces the last 3 characters of my String with "...". Since I'm not using a monospace font this will always be different depending on the letters used in my String. So I'm wondering what's the best way to get the last 3 characters of a String in a TextView and replace them. Maybe there's already something implemented in the Android framework, since this must be a common problem.

推薦答案

你應該能夠使用文本視圖的ellipsize"屬性:

You should be able to use the "ellipsize" property of a text view:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/text_mytext"
    android:ellipsize="end"
    android:maxLines="1"
/>

您可能還需要對布局應用重力值;我有時會看到沒有它們的自動拉伸"視圖.

You may also need to apply gravity values to the layout too; I have sometimes seen "auto-stretching" views without them.

這篇關于Android:TextView 自動截斷并替換字符串的最后 3 個字符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 免费一区二区 | 97影院2| 夜夜操av| 成人h视频在线 | 欧美综合自拍 | 国产成人短视频在线观看 | 国产福利在线 | 全免费a级毛片免费看视频免 | 久久精品一区 | 欧美性video| 日本精品一区二区三区在线观看 | 我我色综合 | 久久久久免费观看 | 国产精品乱码一区二三区小蝌蚪 | 欧美一区二区三区,视频 | 观看av | 一区二区免费看 | 国产精品久久久久久一区二区三区 | 97国产一区二区 | 国产精品视频偷伦精品视频 | 国产精品一卡二卡三卡 | 婷婷久久精品一区二区 | 超碰97人人人人人蜜桃 | 日本精品久久 | 日本一二三区高清 | 欧美福利影院 | 激情久久av一区av二区av三区 | 亚洲一区二区av在线 | 蜜桃传媒一区二区 | 91精品国产综合久久久久久蜜臀 | 免费人成激情视频在线观看冫 | www.黄色在线观看 | 国产日韩欧美在线观看 | 亚洲成人精品国产 | a爱视频 | 一级a性色生活片久久毛片波多野 | 日韩精品中文字幕一区二区三区 | 羞羞网站在线观看 | 成人在线免费观看视频 | 欧美日韩网站 | 91久久久久久久 |