2017-09-06 24 views
4

我遇到的问题是在应用程序中更改本地化时,某些单词的字符长度比以前的语言长,因此按钮的大小问题就像它们最初仅用于英语一样。按钮文字太大autosize?

英语语言环境截图

enter image description here

西班牙语语言环境截图

enter image description here

我知道我可以添加机器人:MAXLINES = “1”但这不会像文本那样解决我的问题太大了。我尝试使用textview auto sizer作为文本大小,但是这并没有解决问题。

有没有人有建议?

+4

https://github.com/grantland/android-autofittextview 这是自动调整的TextView,并且一定会解决你的万阿英,蒋达清 –

+0

还检查了[安卓Ø的文本视图自动调整大小(https://开头开发商。 android.com/guide/topics/ui/look-and-feel/autosizing-textview.html),它也出现在支持库中。 – Cheticamp

+0

@AdeelTurk谢谢,我现在就试试这个。 –

回答

0

感谢@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>