android - Horizonal LinearLayouts in a Vertical LinearLayout -


i want few edittexts buttons on right. right have edittexts filling parent 0dp trick. if add button height of edittext shrink wrap_content. if match_parent 1 edittext fills entire screen.

relativelayout doesn't work because can't make match parent in same way linearlayout.

i thought of getting screen height , setting layout height 1/7 (since have 7 edittexts). plausible?

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="horizontal">     <edittext android:id="@+id/box_0"         android:layout_weight="1"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:hint="@string/edit_task"         android:saveenabled="true"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"/>     <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="@string/button_send"         android:layout_gravity="end"/>     <!--red-->     </linearlayout> <edittext android:id="@+id/box_1"     android:layout_weight="1"     android:layout_width="match_parent"     android:layout_height="0dp"     android:saveenabled="true"     android:inputtype="textcapsentences"     android:maxlength="32"     android:padding="10dp"/> <edittext android:id="@+id/box_2"     android:layout_weight="1"     android:layout_width="match_parent"     android:layout_height="0dp"     android:saveenabled="true"     android:inputtype="textcapsentences"     android:maxlength="32"     android:padding="10dp"/> <edittext android:id="@+id/box_3"     android:layout_weight="1"     android:layout_width="match_parent"     android:layout_height="0dp"     android:saveenabled="true"     android:inputtype="textcapsentences"     android:maxlength="32"     android:padding="10dp"/> <edittext android:id="@+id/box_4"     android:layout_weight="1"     android:layout_width="match_parent"     android:layout_height="0dp"     android:saveenabled="true"     android:inputtype="textcapsentences"     android:maxlength="32"     android:padding="10dp"/> <edittext android:id="@+id/box_5"     android:layout_weight="1"     android:layout_width="match_parent"     android:layout_height="0dp"     android:saveenabled="true"     android:inputtype="textcapsentences"     android:maxlength="32"     android:padding="10dp"/> <edittext android:id="@+id/box_6"     android:layout_weight="1"     android:layout_width="match_parent"     android:layout_height="0dp"     android:saveenabled="true"     android:inputtype="textcapsentences"     android:maxlength="32"     android:padding="10dp"/> </linearlayout> 

i did double linearlayout in first edittext.

http://i.imgur.com/t4hn6no.jpg

see how second 1 larger rest compensate , first smaller?

why don't add scrollview in there? there tons of devices never fit correctly 7 edittext in screen.

anyway it's not raccomended use nested linearlayout weight. can achive want way.

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     android:orientation="horizontal">      <edittext         android:id="@+id/box_0"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:hint="@string/edit_task"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"         android:saveenabled="true" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end"         android:text="@string/button_send" />     <!--red--> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     android:orientation="horizontal">      <edittext         android:id="@+id/box_1"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:hint="@string/edit_task"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"         android:saveenabled="true" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end"         android:text="@string/button_send" />     <!--red--> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     android:orientation="horizontal">      <edittext         android:id="@+id/box_2"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:hint="@string/edit_task"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"         android:saveenabled="true" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end"         android:text="@string/button_send" />     <!--red--> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     android:orientation="horizontal">      <edittext         android:id="@+id/box_3"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:hint="@string/edit_task"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"         android:saveenabled="true" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end"         android:text="@string/button_send" />     <!--red--> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     android:orientation="horizontal">      <edittext         android:id="@+id/box_4"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:hint="@string/edit_task"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"         android:saveenabled="true" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end"         android:text="@string/button_send" />     <!--red--> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     android:orientation="horizontal">      <edittext         android:id="@+id/box_5"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:hint="@string/edit_task"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"         android:saveenabled="true" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end"         android:text="@string/button_send" />     <!--red--> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     android:orientation="horizontal">      <edittext         android:id="@+id/box_6"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:hint="@string/edit_task"         android:inputtype="textcapsentences"         android:maxlength="32"         android:padding="10dp"         android:saveenabled="true" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end"         android:text="@string/button_send" />     <!--red--> </linearlayout> 

a better solution require bit more work is, said, calculating height screenheight/7


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -