android - Layout is beyond the right margin -
i have listview in activity.
each listview item use (in array adapter) layout:
<gridlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="top" android:background="#ffffff" android:columncount="2" android:rowcount="1" > <gridlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="0" android:layout_gravity="left|top" android:layout_margin="5dp" android:layout_row="0" android:rowcount="3" > <textview android:id="@+id/settingsheader" android:layout_column="0" android:layout_gravity="left|top" android:layout_row="0" android:text="large text" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/settingscontent" android:layout_column="0" android:layout_gravity="left|top" android:layout_row="2" android:layout_width="match_parent" android:text="small text" android:textappearance="?android:attr/textappearancesmall" /> </gridlayout> <switch android:id="@+id/settingstoggle" android:layout_column="1" android:layout_marginright="5dp" android:layout_gravity="center_vertical|right" android:layout_row="0"/> </gridlayout>
but problem is, layout beyond right margin. think it's because textview settingscontent
not wrap text. how can solve problem?
add these piece of code textview settingscontent.
android:ellipsize="end" android:ems="9" android:lines="1" android:singleline="true"
set width of 1st gridlayout 'fill_parent'.
xml this:
<gridlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="top" android:background="#ffffff" android:columncount="2" android:rowcount="1" > <gridlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="0" android:layout_gravity="left|top" android:layout_margin="5dp" android:layout_row="0" android:rowcount="3" > <textview android:id="@+id/settingsheader" android:layout_column="0" android:layout_gravity="left|top" android:layout_row="0" android:ellipsize="end" android:ems="9" android:lines="1" android:singleline="true" android:text="large text" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/settingscontent" android:layout_column="0" android:layout_gravity="left|top" android:layout_row="2" android:layout_width="match_parent" android:ellipsize="end" android:ems="9" android:lines="1" android:singleline="true" android:text="small text" android:textappearance="?android:attr/textappearancesmall" /> </gridlayout> <switch android:id="@+id/settingstoggle" android:layout_column="1" android:layout_marginright="5dp" android:layout_gravity="center_vertical|right" android:layout_row="0"/>
this might you.
Comments
Post a Comment