4
我遇到的問題是在應用程序中更改本地化時,某些單詞的字符長度比以前的語言長,因此按鈕的大小問題就像它們最初僅用於英語一樣。按鈕文字太大autosize?
英語語言環境截圖
西班牙語語言環境截圖
我知道我可以添加機器人:MAXLINES = 「1」但這不會像文本那樣解決我的問題太大了。我嘗試使用textview auto sizer作爲文本大小,但是這並沒有解決問題。
有沒有人有建議?
我遇到的問題是在應用程序中更改本地化時,某些單詞的字符長度比以前的語言長,因此按鈕的大小問題就像它們最初僅用於英語一樣。按鈕文字太大autosize?
英語語言環境截圖
西班牙語語言環境截圖
我知道我可以添加機器人:MAXLINES = 「1」但這不會像文本那樣解決我的問題太大了。我嘗試使用textview auto sizer作爲文本大小,但是這並沒有解決問題。
有沒有人有建議?
感謝@AdeelTurk提供此答案。我能夠用我的按鈕使用autofittextview,但它很複雜這裏是我如何使用LinearLayout通常不適用於此API的示例。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_footer_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F0F0">
<me.grantland.widget.AutofitLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1">
<Button
android:id="@+id/button_assessments_review"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/button_assessments_review" />
</me.grantland.widget.AutofitLayout>
<me.grantland.widget.AutofitLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1">
<Button
android:id="@+id/button_assessments_select"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/button_assessments_select"
android:maxLines="1"/>
/>
</me.grantland.widget.AutofitLayout>
<me.grantland.widget.AutofitLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1">
<Button
android:id="@+id/button_assessments_discuss"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/button_assessments_discuss"
android:maxLines="1"/>
</me.grantland.widget.AutofitLayout>
<me.grantland.widget.AutofitLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1">
<Button
android:id="@+id/button_assessments_action_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/button_assessments_action_items"
android:maxLines="1"/>
/>
</me.grantland.widget.AutofitLayout>
<me.grantland.widget.AutofitLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1">
<Button
android:id="@+id/button_assessments_finish_session"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/button_assessments_finish_session" />
</me.grantland.widget.AutofitLayout>
</LinearLayout>
</LinearLayout>
https://github.com/grantland/android-autofittextview 這是自動調整的TextView,並且一定會解決你的萬阿英,蔣達清 –
還檢查了[安卓Ø的文本視圖自動調整大小(https://開頭開發商。 android.com/guide/topics/ui/look-and-feel/autosizing-textview.html),它也出現在支持庫中。 – Cheticamp
@AdeelTurk謝謝,我現在就試試這個。 –