Atharva
Atharva

Reputation: 6969

How to set property of a view in layout XML file in Android?

For example, I am using android.support.v4.view.PagerTabStrip and I want to call its setTabIndicatorColor with my choice of color. How to do it in layout XML file?

Upvotes: 1

Views: 359

Answers (1)

Szymon
Szymon

Reputation: 43023

Best thing you can do is to consult the documentation. For PagerTabStrip it is here.

There's a Summary section where you can check all XML attributes defined for that class. In this case, you can see that there are only attributes inherited from ViewGroup and View. None of them sets the tab indicator color.

This means that you need to set it in the code.

Let's look at the example where there is an attribute, e.g. orientation for LinearLayout. There's a entry for android:orientation attribute which tells you exactly how to set it in XML.

Upvotes: 1

Related Questions