android - LinearLayout height change with adding new view -


i have nested layouts in gui. don't ask me why made or why don't use grid layout...my question else.

my layout looks this

after add view, let's button, of these 4 relative layouts, changes this

i set relative layout's weight 0dp. way, width not changed when add view layout. don't know height. if set 0dp well, ofc, disappears.

here xml code:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"  android:background="@drawable/rising_sun_blue" android:weightsum="2">  <linearlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"      android:layout_weight="1"     android:background="#333111"     android:weightsum="2"     android:layout_alignparentbottom="true"     >      <relativelayout         android:layout_width="0dp"         android:layout_height="match_parent"          android:layout_weight="1"         android:background="#ffffff">     </relativelayout>      <relativelayout         android:layout_width="0dp"         android:layout_height="match_parent"         android:layout_weight="1"         android:background="#ff0000" >          <button             android:id="@+id/button1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_alignparenttop="true"             android:layout_centerhorizontal="true"             android:layout_margintop="14dp"             android:text="button" />      </relativelayout>  </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"      android:layout_weight="1"     android:background="#123132"     android:weightsum="2"     android:layout_alignparenttop="true">       <relativelayout         android:layout_width="0dp"         android:layout_height="match_parent"          android:layout_weight="1"         android:background="#ff0000">     </relativelayout>      <relativelayout         android:layout_width="0dp"         android:layout_height="match_parent"          android:layout_weight="1"         android:background="#ffffff">     </relativelayout>   </linearlayout> </linearlayout> 

so, question is, there piece of code "glue" layouts , make them stay on first screenshot, after add bunch of new views in !?

give both nested linearlayouts android:layout_height="match_parent" , not wrap_content.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -