JJD
JJD

Reputation: 51884

Button text not visible when using android:singleLine and android:autoLink

I use the following style to layout a button:

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

The button itself is nested in some LinearLayouts which are wrapped in a ExpandableListView:

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

In a subclass of BaseExpandableListAdapter I dynamically set the text for each instance of the button:

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

When I expand an item of the ExpandableListView the button is shown (see button in "Number 2" and "Number 4"). However there is no text rendered on it. The moment I touch the button the text appears (see button in "Number 3").

ExpandableListView


Experiments

Upvotes: 2

Views: 558

Answers (1)

goemic
goemic

Reputation: 1339

I know this question is quite a bit old but I faced similar problems. In my case I had to set the "android:textColorLink" attribute in the xml additionally to the autoLink attribute. The behaviour is the same for TextView.

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

Probablby it won't help you but hopefully someone else :)

Upvotes: 1

Related Questions