簡體   English   中英

Android文本會在某些設備上被剪裁

[英]Android text gets clipped on some devices

我在一部手機中面臨一個問題(直到現在)。 我的應用使用印地語字體。 它在模擬器,標簽,許多其他手機上也很好用。 但是我用於測試目的的一部手機正在顯示從側面切割的文字。

我嘗試了幾乎所有的東西,因為它按正確的順序排列,但都沒有用。 這里張貼了我的兩部測試手機和文字的截圖。

錯誤的屏幕截圖:

http://virtualcolors.net/akki/stmd/error.jpg

其他手機的截圖:以及預期的手機:

http://virtualcolors.net/akki/stmd/correct.jpg

可能是什么原因,我該如何解決? 請告訴我!!

我使用的TextView配置:

<TextView
    android:id="@+id/A_lbl_mandir"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/Abt_mandir"
    android:textAlignment="center"
    android:textColor="#80000A"
    android:textSize="35sp" />

編輯:我的完整活動xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:id="@+id/text"
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:text="@string/hello_world" />
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/text" >
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:padding="5sp"
    android:text="@string/test"/>
</ScrollView>

</RelativeLayout>

我試過並刪除了許多其他東西,尤其是這款手機。 但無法解決問題!

這發生在4.1.2中,並記錄為谷歌中的一個錯誤,他們已在4.2中修復。

https://code.google.com/p/android/issues/detail?id=34432

這種情況發生在unicode字體中,其中Android OS無法計算文本的長度。

行! 找到另一部同樣問題的手機。 在那部手機中,文字也被剪裁了。 我猜電話有問題。 因為即使像Whatsapp這樣的熱門應用也在該設備上遇到了同樣的問題。 印地語文本被剪切為與上圖中所示相同。

可能解決了這個問題:(如果有人得到了我現在正在做的事情。)我意識到瀏覽器顯示了hindi字體。 因此,最好在html,javascript上制作本機應用程序,尤其是對於此類設備,並使用WebView查看HTML。應用程序將變得有點慢,但我們必須這樣做直到我們得到實際問題創建它。

請注意:這不是一個解決方案,而是一個解決方案,使這項工作。 在印地語中被稱為“JUGAAD”。

試試這個。

<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_below="@id/text" 
android:padding="5dp">
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="20sp"
  android:gravity="left" 
  android:padding="5sp"
  android:text="@string/test"/>
</ScrollView>

在某些手機上(特別是在三星手機上),某些自定義字體會被刪除(或剪裁)。 我有自定義斜體字體。 有人說你可以編輯字體來添加某種填充(我無法確認,因為我缺乏編輯字體的知識)但是: - EditText / TextView從xml添加一些填充 - Ellipsize(在某些設備上弄亂這有助於正確顯示文字)

您也可以使用已啟用的開發人員選項發布屏幕截圖來繪制布局邊界,如果上述解決方案無法解決問題,這可能有助於解決您的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM