0

In XML it's easy to set listSeparatorTextViewStyle:

<TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Title"
        android:textSize="16dp"
        style="?android:attr/listSeparatorTextViewStyle"/>

But how do I set the style attribute in java?

haansn08
  • 157
  • 3
  • 10

1 Answers1

0

You can't change style attribute at runtime. You must set the style before the view is created i.e. at compile time in your xml.

However you can somewhat achieve it by setTextAppearance or setTextTypeface.

Even if this doesn't help then there is a workaround to do this explained on the link mentioned below :

android set style in code

If you just want a divider then simply use this below your TextView :

<View
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="@android:color/grey"/>
Community
  • 1
  • 1
CodeWarrior
  • 5,026
  • 6
  • 30
  • 46