// try this way,hope this will help you...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp">
<TextView
android:text="test"
android:id="@+id/file_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textAppearance="?android:textAppearanceLarge" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:contentDescription="@string/image_placeholder"
android:layout_marginLeft="5dp"/>
<ImageView
android:id="@+id/show_file_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_next_item"
android:contentDescription="@string/image_placeholder"
android:layout_marginLeft="5dp"
android:clickable="true"/>
</LinearLayout>
maximum TextView width in layout file
-
21-07-2023 - |
Question
i have a small layout file for the parentView of the ExpandableListView.
If the TextView text is too long it overlays some other views of the layout.
Here is an image: enter link description here
and here is the layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="test"
android:id="@+id/file_name"
android:layout_marginLeft="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textAppearance="?android:textAppearanceLarge"
android:layout_centerVertical="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_icon_line"
android:contentDescription="@string/image_placeholder"
android:layout_toLeftOf="@+id/show_file_detail"
android:layout_centerVertical="true"/>
<ImageView
android:id="@+id/show_file_detail"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_next_item"
android:contentDescription="@string/image_placeholder"
android:clickable="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
I already google'd the problem but the answers were not so specific.
I tried it with android:layout_toLeftOf the the long text right aligned and if an short text is shown, it looks aweful.
Does anyone of you guys have an idea?
Greets
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow