android - Table Layout column taxt right align -
in tablelayout have align text in first column right , third column text left (my second column dummy column spacing). aligning right problem . have 1 concern if content in second column doesn't fit in 1 line how make continue on second line because if entering big text in second column trying fit in 1 line , going out of mobile screen width.
<?xml version="1.0" encoding="utf-8"?> <tablelayout android:id="@+id/widget35" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:stretchcolumns="0,2" xmlns:android="http://schemas.android.com/apk/res/android"> <tablerow android:id="@+id/widget43" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <linearlayout android:id="@+id/widget33" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/red"> <textview android:id="@+id/widget36" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textview in rightassaasas" android:layout_gravity="top|right" /> </linearlayout> <linearlayout android:id="@+id/widget33" android:layout_width="5dip" android:layout_height="wrap_content" android:background="@color/white"> <textview android:id="@+id/widget36" android:layout_width="2dip" android:layout_height="wrap_content" /> </linearlayout> <linearlayout android:id="@+id/widget37" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/green"> <textview android:id="@+id/widget38" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textview" android:layout_gravity="left" /> </linearlayout> </tablerow> <tablerow android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <linearlayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/red"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textview" android:layout_gravity="right" /> </linearlayout> <linearlayout android:layout_width="5dip" android:layout_height="wrap_content" android:background="@color/white"> <textview android:layout_width="2dip" android:layout_height="wrap_content" /> </linearlayout> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/green"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textview" android:layout_gravity="left" /> </linearlayout> </tablerow>
your layout seems unnecessarily complex, need single linearlayout 2 textviews gravity set properly. can use layout_margin create spacing "middle column", this:
<tablerow android:id="@+id/widget43" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <linearlayout android:id="@+id/widget33" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:id="@+id/widget36" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textview in rightassaasas" android:layout_gravity="top|right" android:gravity="right" android:layout_marginright="5dp" android:background="@color/red" /> <textview android:id="@+id/widget38" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textview" android:layout_gravity="left" android:gravity="left" android:layout_marginleft="5dp" android:background="@color/green" /> </linearlayout> </tablerow>
Comments
Post a Comment