Themes for Android - How to set the style only for certain types of viewing

Is it possible to create a theme that will set styles only for certain types of views? For example, if I want the background for FrameLayout objects FrameLayout be the same color, but leave all other views with the default background color of the theme, how would I do this?

The CSS parameter will be div {background-color:#000000;} . How can i do this in android?

Edit: I found something only for TextView : android:textViewStyle , and you can choose a style only for TextView s. But what about other views? Even custom views? FrameLayout view specifically?

+7
source share
1 answer

If you have, for example, two FrameLayouts, and you want only 1 to have a cetrain style, you should add style = "@ style / application_list_entry" to the layout of the frame you want to change.

styles.xml

Make style:

 <style name="container"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">fill_parent</item> <item name="android:background">@drawable/bg_landscape</item> <item name="android:textColor">@color/white</item> // set color here <item name="android:orientation">vertical</item> </style> 

my_layout.xml

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent> <FrameLayout style="@style/application_list_entry" > //this FrameLayout will be different from the one below </FrameLayout> <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" > </FrameLayout> </LinearLayout> 

Hope this is what you were looking for.

Greetings

0
source

All Articles