久久久久久久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(使用線程逐塊處理文件)
主站蜘蛛池模板: 欧美一区二区三区视频 | 国产精品福利在线观看 | 久久偷人| 久久久久久国产精品 | 欧美日韩中文在线 | 久久精品欧美一区二区三区不卡 | 亚洲一区二区免费视频 | 九色www| 国产精品国产三级国产aⅴ中文 | av网址在线播放 | 中文字幕不卡在线观看 | 国产福利91精品一区二区三区 | 自拍偷拍一区二区三区 | 性大毛片视频 | 成人免费一区二区三区牛牛 | 一区视频在线免费观看 | 人人鲁人人莫人人爱精品 | 一区二区在线观看av | 国产999在线观看 | 一区二区三区在线观看视频 | 第一区在线观看免费国语入口 | 日本爱爱视频 | 国产91视频免费 | 亚洲精品中文在线 | 中文字幕久久久 | 色在线视频网站 | 成人美女免费网站视频 | 天堂一区二区三区 | 麻豆精品久久 | 亚洲视频在线观看免费 | 亚洲精品久久久久久久久久久久久 | 国产精品一区二区三区免费观看 | 国产视频福利一区 | 九九久久久| 欧美精品在线播放 | 免费在线观看一级毛片 | 一区二区三区在线看 | 九一视频在线观看 | 在线观看视频91 | 久久久一二三区 | 久久亚洲一区二区 |