【问题标题】:Using AutofitTextView with Button使用带有按钮的 AutofitTextView
【发布时间】:2016-06-08 16:10:35
【问题描述】:

我在我的应用程序中使用 AutofitTextView,它与 TextView 小部件一起工作正常,但我无法让它与按钮一起工作。我尝试将 xml 添加到 Button xml。

我希望使用按钮重新调整文本大小。

下面是我的代码:

  <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>

任何帮助将不胜感激。

【问题讨论】:

  • Button 不是 groupView,因此您不能在按钮视图中添加另一个视图
  • 您不能将AutofitTextView 放在Button 中。在开始 AutofitTextView 之前,您需要删除 &lt;/Button&gt; 并结束按钮标签

标签: android xml android-widget


【解决方案1】:

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

Click Here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-11
    • 2018-01-20
    • 2015-05-18
    • 2012-11-04
    相关资源
    最近更新 更多