2016-02-25 41 views
0

我在我的應用程序中使用了AutofitTextView,它可以正常使用TextView小部件,但是我無法使它與按鈕一起工作。我試過把xml添加到Button xml中。與按鈕一起使用AutofitTextView

我希望文本通過按鈕重新調整大小。

下面是我的代碼:

<Button 
    android:id="@+id/showAnswerButton" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_weight="7" 
    android:background="#000000" 
    android:text="Show Answer" > 

    <me.grantland.widget.AutofitTextView 
    xmlns:ads="http://schemas.android.com/apk/libs/me.grantland.widget.AutofitTextView" 
    android:id="@+id/textView10" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:singleLine="true" 
    android:text="@string/app_name" 
    android:textSize="50sp" />  
    </Button> 

任何幫助,將不勝感激。

+0

按鈕是不是groupView所以你不能添加一個按鈕視圖 – Inducesmile

+0

不能放置'AutofitTextView'了'Button'內內的另一個觀點。您需要刪除''並在啓動'AutofitTextView'之前結束按鈕標記 –

回答

0

好消息! Google在Android O中引入了Auto fit textview支持,它也將包含在支持庫中。

Click Here

相關問題