Solution 1 :
We have to give a Start and End for alignment instead of Left and Right because for multilanguage (localization) it won’t support.
Example:
Case 1: In Arabic, Text starts from Right to Left
Case 2: In English, Text starts from Left to Right
Changes in TextView:
Add these lines,
android_textAlignment="center"
android_layout_toEndOf="@+id/previous_button"
android_layout_toStartOf="@+id/next_button"
Need to remove this Code in TextView,
android_layout_centerHorizontal="true"
Full sample code try this,
<RelativeLayout
android_layout_width="match_parent"
android_layout_height="wrap_content">
<ImageView
android_id="@+id/previous_button"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_alignParentStart="true"
android_layout_marginStart="5dp"
android_layout_marginTop="5dp"
android_layout_marginEnd="5dp"
android_layout_marginBottom="5dp"
android_src="@drawable/img1"
tools_ignore="ContentDescription" />
<TextView
android_id="@+id/txt1"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_centerVertical="true"
android_text="@string/name"
android_textAlignment="center"
android_layout_toEndOf="@+id/previous_button"
android_layout_toStartOf="@+id/next_button"
android_textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android_textColor="@color/black" />
<ImageView
android_id="@+id/next_button"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_alignParentEnd="true"
android_layout_margin="5dp"
android_src="@drawable/img2"
tools_ignore="ContentDescription"/>
</RelativeLayout>
Problem :
I have a RelativeLayout that contains two ImageViews (one at the left and the other one at the right) and one TextView (at the center)
This is what I have:
<RelativeLayout
android_layout_width="match_parent"
android_layout_height="wrap_content">
<ImageView
android_id="@+id/previous_button"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_alignParentStart="true"
android_layout_marginStart="5dp"
android_layout_marginTop="5dp"
android_layout_marginEnd="5dp"
android_layout_marginBottom="5dp"
android_src="@drawable/img1"
tools_ignore="ContentDescription" />
<TextView
android_id="@+id/txt1"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_centerHorizontal="true"
android_layout_centerVertical="true"
android_text="@string/name"
android_textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android_textColor="@color/black" />
<ImageView
android_id="@+id/next_button"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_alignParentEnd="true"
android_layout_margin="5dp"
android_src="@drawable/img2" />
</RelativeLayout>
I have seen the following warning in the TextView (txt1):
If relative layout has text or button items aligned to left and right
sides they can overlap each other due to localized text expansion
unless they have mutual constraints like toEndOf/toStartOf.
I have been searching for information from other posts but I have not seen it clearly how could I solve it in my case. I would appreciate all the possible help. Thanks