I'm new to android development and I've stumbled upon a problem I couldn't solve with the help of existing StackOverflow questions.
In the list of custom items I'm loading a TextView object which can use 2 different styles (both defined in styles.xml) - if there's a secondary TextView object, the style applied is itemHeadingText_Medium, and if not it's itemHeadingText_Large. I'm changing the style programmaticaly in the ListItemAdapter class.
bold
@android:color/black
100dp
center_vertical
bold
@android:color/black
Sadly, the android:layout_height and android:gravity aren't applied to the view, and whole app looks like that. Here's how both TextViews are defined:
android:id="@+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"/>
android:id="@+id/secondary"
style="@style/itemSecondaryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/holo_red_light"/>
I would like to center vertically the Lorem Ipsum heading of the second item provided in the screenshot.
EDIT: 25 June 2017
I managed to achieve what I wanted by changing the height programmatically using the getLayoutParams().height and adding the android:gravity attribute to the TextView xml definition - after all in both styles text can be centered vertically within its TextView.
Nevertheless, my question on how to do that in styles.xml is still open!