android - How to make all buttons to be of the same height (and keep their weigths)? -


enter image description here

<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"     android:weightsum="6"     tools:context=".mainactivity" >      <button          android:text="btn1"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1" />     <button          android:text="btn2"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="2" />     <button          android:text="btn3"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1" />     <button          android:text="btn4"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1" />     <button          android:text="btn5"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1" />  </linearlayout> 

using android:layout_height="match_parent" stretches buttons whole screen height. want button 2 twice wide other buttons.

this do:

<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="wrap_content"     android:orientation="horizontal"     android:weightsum="6"     tools:context=".mainactivity" >      <button         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1"         android:text="btn1" />      <button         android:layout_width="0dp"         android:layout_height="match_parent"         android:layout_gravity="fill_vertical"         android:layout_weight="2"         android:text="btn2" />      <button         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1"         android:text="btn3" />      <button         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1"         android:text="btn4" />      <button         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="fill_vertical"         android:layout_weight="1"         android:text="btn5" />  </linearlayout> 

make parent layout height wrap_content , 2nd button's height match_parent

enter image description here


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -