When i add long text to my TextView
in linear layout it takes up all the space, and other views get squeezed. I set layout_width="0"
to every view but it did not help. I should also add that this layout is used in RecyclerView
.
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100">
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/lp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Lp"
android:layout_weight="5" />
//this TextView takes all the space if text is long, but it behaves normally if text is short
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/nazwa"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Końcówka Yankauer do odsysania pola operacyjnego CH 23 (4 otwory boczne) z kontrolą odsysania"
android:layout_weight="20"/>
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/ilosc"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="#"
android:layout_weight="5" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/jednostka"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="JM"
android:layout_weight="15" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/cenaNetto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="C. net."
android:layout_weight="15" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/wartNetto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="W.net."
android:layout_weight="15" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/wartVAT"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="VAT"
android:layout_weight="10" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="@+id/wartBrutto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="W. brut."
android:layout_weight="15" />
</android.support.v7.widget.LinearLayoutCompat>
Here is a print screen of what breaks in my app link
Please try below link code as a demo I hope you will get your result.
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/row_my_booking_unit_name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
</TextView>
<TextView
android:id="@+id/row_my_booking_unit_quantity"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
</TextView>
<TextView
android:id="@+id/row_my_booking_unit_amount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
</TextView>
</LinearLayout>
</TableRow>
</TableLayout>