【问题标题】:Button text not visible when using android:singleLine and android:autoLink使用 android:singleLine 和 android:autoLink 时按钮文本不可见
【发布时间】:2013-10-23 17:51:04
【问题描述】:

我使用以下样式来布局按钮:

<style name="Button.Web" parent="@android:style/TextAppearance.Small">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:singleLine">true</item>
    <item name="android:autoLink">web</item>
</style>

按钮本身嵌套在一些LinearLayouts 中,这些ExpandableListView 包裹在其中:

<Button
    android:id="@+id/button_web"
    style="@style/Button.Web" />

BaseExpandableListAdapter 的子类中,我为按钮的每个实例动态设置文本:

Button buttonWeb = (Button) convertView.findViewById(R.id.button_web);
buttonWeb.setText("http://www.example.com/" + page);

当我展开 ExpandableListView 的一个项目时,会显示该按钮(请参阅“数字 2”和“数字 4”中的按钮)。然而,它上面没有呈现文本。当我触摸按钮时,文本出现(参见“数字 3”中的按钮)。


实验

【问题讨论】:

    标签: android expandablelistview textview android-xml android-button


    【解决方案1】:

    我知道这个问题有点老了,但我遇到了类似的问题。在我的情况下,我必须将 xml 中的“android:textColorLink”属性另外设置为 autoLink 属性。 TextView 的行为是相同的。

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:autoLink="phone|email"
        android:textColorLink="@color/yourDesiredLinkColor"/>
    

    可能对你没有帮助,但希望其他人:)

    【讨论】:

      猜你喜欢
      • 2021-04-27
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      相关资源
      最近更新 更多