android - two tableLayout inside a linearLayout -
i place 2 table layout within linear layout, code, can see 1 table. that's code:
<linearlayout 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=".mainactivity" > <tablelayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:stretchcolumns="1" > <tablerow android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" > <textview android:id="@+text_view/tw_nome" android:text="@string/tw_nome" /> <edittext android:id="@+edit_text/et_nome" android:hint="@string/et_nome" android:imeoptions="actionnext" android:singleline="true" /> </tablerow> <tablerow android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" > <textview android:id="@+text_view/tw_cognome" android:text="@string/tw_cognome" /> <edittext android:id="@+edit_text/et_cognome" android:hint="@string/et_cognome" android:imeoptions="actiondone" android:singleline="true" /> </tablerow> </tablelayout> <tablelayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" > <tablerow android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" > <textview android:id="@+text_view/tw_sesso" android:text="@string/tw_sesso" /> <radiogroup android:id="@+radio_group/rg" android:orientation="horizontal" > <radiobutton android:id="@+radio_button/button_m" android:text="@string/button_m" /> <radiobutton android:id="@+radio_button/button_f" android:text="@string/button_f" /> </radiogroup> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" > <button android:id="@+button/button_salva" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_salva" /> <button android:id="@+button/button_annulla" android:text="@string/button_annulla" /> </tablerow> </tablelayout>
what's wrong?
side-by-side or vertical?
if you're looking side-by-side, seek layout_weight
. note alter in layout_width
.
<linearlayout 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" android:orientation="horizontal" tools:context=".mainactivity" > <tablelayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:stretchcolumns="1" > <!-- rows --> </tablelayout> <tablelayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:stretchcolumns="1" > <!-- rows --> </tablelayout> </linearlayout>
update comments asked why layout_width
should set 0dp
.
setting 0dp
optimization when utilize layout_weight
. setting width 0dp
tells layout ignore layout_height
, utilize layout_weight
instead in case gives width each tablelayout
.
i asked same question , got useful answers if it's helpful why 0dp considered performance enhancement?
android android-layout android-linearlayout android-tablelayout
No comments:
Post a Comment