I have the following issue. My list view elements consist of two buttons positioned in a row:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp">
<Button
android:id="@+id/time_field"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/task_field"
android:layout_alignTop="@+id/task_field"
android:layout_centerVertical="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:clickable="false"
android:enabled="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:longClickable="false"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@color/black_col" />
<Button
android:id="@+id/task_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/time_field"
android:clickable="false"
android:enabled="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center|start"
android:longClickable="false"
android:paddingLeft="10dp"
android:paddingRight="10dp"/>
So what happens im the app is that the second (right) button is got filled with the text (by user) which can be of 2, 3 and more lines, whereas text in the left button is always in single line. So, what I want is to make the first (left) button be always of the same height as the right one, which varies depending on the number of text lines. Also the text line in the left button should be in the center.
Now I only can make buttons of equal height (using layout_alignBottom and layout_alignTop) but the text in the left button is always on top.
As far as I understand this happens due to rendering of the list view item is completed after the height is set, but I don't know how to overcome this. I've tried to set left button height equal to the right one programmatically in my list view adapter but it helps only when I tap on a list view item and not when the list is filled or scrolled!
Please help me to overcome this! Thanks!