xml - Simple Android Layout Resize -


i'm attempting resize buttons on rotate expand proportionately. right now, fix length, i'm unsure of alternative method buttons resize (setting weight doesn't seem help). want buttons fill length of screen both vertically , horizontally. please let me know if need more information.

 <linearlayout             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_margintop="5dp"             android:layout_gravity="center_vertical" >              <button                 android:id="@+id/maincommentbtn"                 android:layout_width="119dp"                 android:layout_height="wrap_content"                 android:layout_alignparentleft="true"                 android:clickable="true"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:layout_weight="1"                 android:text="@string/commentbtn" />              <button                 android:id="@+id/mainprofilebtn"                 android:layout_width="119dp"                 android:layout_height="wrap_content"                 android:clickable="true"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:layout_weight="1"                 android:layout_centerinparent="true"                 android:text="@string/profilebtn" />              <button                 android:id="@+id/maindetailbtn"                 android:layout_width="119dp"                 android:clickable="true"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:layout_weight="1"                 android:layout_height="wrap_content"                 android:layout_alignparentright="true"                 android:text="@string/sharebtn" />         </linearlayout> 

replace resource this. copy edited changes

notice how there width 0dp because using weight. using weight: 1. in order use weight need set weightsum in parent. 2. make sure width or height set 0 according how using weight. (for instance since going horizontal orientation want use "0dp" width. allows weight control width of object. 3. lastly make sure weight of objects add weightsum.

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_margintop="5dp" android:orientation="horizontal" android:weightsum="3" >  <button     android:id="@+id/maincommentbtn"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:layout_alignparentleft="true"     android:layout_weight="1"     android:clickable="true"     android:focusable="false"     android:focusableintouchmode="false"     android:text="@string/commentbtn" />  <button     android:id="@+id/mainprofilebtn"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:layout_centerinparent="true"     android:layout_weight="1"     android:clickable="true"     android:focusable="false"     android:focusableintouchmode="false"     android:text="@string/profilebtn" />  <button     android:id="@+id/maindetailbtn"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:layout_alignparentright="true"     android:layout_weight="1"     android:clickable="true"     android:focusable="false"     android:focusableintouchmode="false"     android:text="@string/sharebtn" />  </linearlayout> 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -