I have an xml
layout file that is used to show a ListView
item. Here is xml
code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/task_item_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_item_background"
android:orientation="horizontal"
android:weightSum="1">
<RelativeLayout
android:id="@+id/task_item_icon_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2">
<ImageView
android:id="@+id/item_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:srcCompat="@android:drawable/stat_notify_sync" />
</RelativeLayout>
<TextView
android:id="@+id/item_text"
android:layout_width="0dp"
android:layout_height="75dp"
android:layout_weight="0.6"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:text="appName"
android:textAlignment="textStart"
android:textSize="20sp" />
<RelativeLayout
android:id="@+id/additional_info_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.19">
<TextView
android:id="@+id/price"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:text="0,1 $"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
I want TextView
with id price
to have gravity value set to center. But when I do it, item_text
somewhy jumps to the center. This behaviour can be seen only in editor, everything is fine on my device.
Layout when price
gravity value is not set:
Layout when price
gravity value is set to center:
Why is this happening and how do I fix this?
UPD: Do not edit my question: I change gravity of price
TextView, and item_text
is the one that changes. This is the strange behaviour I am asking about.