Sunday, 15 August 2010

android - Why does my TableLayout not display properly when running on API Level 10 or below? -



android - Why does my TableLayout not display properly when running on API Level 10 or below? -

my app uses tablelayout show info user. when run app on device (or avd) api level 11 or higher, table displays intended.

however, utilize avd api level of 10 or lower, tableviews no longer show margin, nor perform android:layout_width="wrap_content"-tag.

does know, why , how can prepare it? margins aren't number 1 priority (it looks ugly), yet content-wrapping is: since table not wrap entire content intended, user not info he's supposed get!

here xml:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".evalactivity" > <scrollview android:id="@+id/scrollviewgeneral" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:background="@drawable/border_surrounded" > <tablelayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" > <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalnumberofproblems" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblproblemscount" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalcorrectsolutions" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblcorrectsolutions" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottombreak" android:text="@string/str_evalwrongsolutions" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblwrongsolutions" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalduration" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblduration" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalaverageduration" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblaverageduration" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalshortestduration" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblshortestduration" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottombreak" android:text="@string/str_evallongestduration" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lbllongestduration" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evaladdition" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lbladdition" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalsubtraction" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblsubtraction" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalmultiplication" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblmultiplication" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evaldivision" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lbldivision" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalpower" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblpower" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="@dimen/margin_evaltableright" android:layout_marginbottom="@dimen/margin_evaltablebottom" android:text="@string/str_evalpercent" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/lblpercent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/lbl_outputdummystring" android:textappearance="?android:attr/textappearancemedium" /> </tablerow> </tablelayout> </scrollview> <scrollview android:id="@+id/scrollviewtable" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignparentright="true" android:layout_torightof="@+id/scrollviewgeneral" android:layout_alignparenttop="true" android:layout_marginleft="0dp" android:layout_marginright="10dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:background="@drawable/border_surrounded" > <tablelayout android:id="@+id/tableviewtable" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" > <!-- content generated programatically! --> </tablelayout> </scrollview> </relativelayout>

to prepare this, need set gravity on table layout. since you're using margins on sides, want android:gravity="center". reason, api < 10 kind of ignores margin if don't set gravity tablelayout.

android xml tablelayout

No comments:

Post a Comment