java - Dynamically updating table layout in android app -
i building app android dynamically updates table layout table rows. way this, having fixed table row layout populate content , insert table layout , displays seen below.
the problem i'm having when add row contains content longer in middle part , creates multiple lines on 1 of text views, somehow shortens width of layout contains 2 text views of other rows (middle part), have single lines, example first , second row in image below.
you can find code below. if need more code or examples, please tell me.
row_main.xml - fixed layout of row.
<?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tablerowmain1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margintop="10dp" android:layout_marginbottom="10dp" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_margin="2dp" android:gravity="center" android:layout_gravity="center" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center" > <textview android:id="@+id/textviewemployeename" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="15sp" android:layout_margin="2dp" android:gravity="center" android:layout_gravity="center"/> <textview android:id="@+id/textviewclientid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="15sp" android:layout_margin="2dp" android:gravity="center" android:layout_gravity="center"/> <textview android:id="@+id/textviewtable" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="15sp" android:layout_margin="2dp" android:gravity="center" android:layout_gravity="center"/> </linearlayout> <textview android:id="@+id/textviewtimestamp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="12sp" android:layout_margin="1dp" android:gravity="center" android:layout_gravity="center"/> </linearlayout> <linearlayout android:id="@+id/linearlayoutorder" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_margin="2dp" android:gravity="center" android:layout_gravity="center" android:layout_weight="1" > <textview android:id="@+id/textvieworder" android:layout_width="match_parent" android:layout_height="wrap_content" android:textsize="15sp" android:textstyle="bold" android:singleline="true" android:ellipsize="marquee" android:layout_weight="1" android:gravity="center" android:layout_gravity="center" /> <textview android:id="@+id/textvieworderdetails" android:layout_width="match_parent" android:layout_height="wrap_content" android:textsize="12sp" android:layout_weight="1" android:layout_margin="0dp" android:gravity="center" android:layout_gravity="center" /> </linearlayout> <button android:id="@+id/buttondelete" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:text="@string/cross" android:textsize="25sp" android:gravity="center" android:layout_gravity="center" /> </merge>
mainactivity.xml (snippet) - table row inserted.
<scrollview android:layout_width="fill_parent" android:layout_height="0dp" android:scrollbars="vertical" android:layout_weight="1" android:layout_margin="10dp" android:overscrollmode="always" > <tablelayout android:id="@+id/tablelayoutmain" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5dp" > </tablelayout> </scrollview>
i can't figure out how solve or may causing it... please help!
thank in advance! :)
note: pink/red rectangles "show layout bonds" tool developer options in android.
edit: replaced tablelayout vertical linearlayout , works fine. guess overcomplicating it... :p