android - Adjust View Height and Width accordingly -


i have following xml implementation. however, see in following, heights , widths hard coded, , though values work on nexus 10. not work on nexus 7.

i need know there way handle percentage?

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:id="@+id/mainview"     android:background="#0000ff"> <view         android:layout_width="220dp"         android:layout_height="wrap_content"         android:id="@+id/view1"         android:background="#000000"         android:layout_alignparenttop="true"         android:layout_alignparentleft="true"         android:layout_alignparentbottom="true" /> <view         android:layout_width="wrap_content"         android:layout_height="360dp"         android:id="@+id/view2"         android:background="#00ff0000"         android:layout_alignparentright="true"         android:layout_alignparenttop="true" /> <linearlayout         android:layout_width="wrap_content"         android:layout_height="44dp"         android:layout_below="@id/view2"         android:id="@+id/view3"         android:background="#000000"         android:layout_alignleft="@id/view2"         android:layout_alignparentright="true">  <view         android:layout_width="wrap_content"         android:layout_height="360dp"         android:layout_torightof="@id/view1"         android:id="@+id/view4"         android:background="#00ff0000"         android:layout_alignparentright="true"         android:layout_alignparenttop="true" /> </relativelayout 

here layout design

enter image description here

the reason not want convert relativelayout linear layout, because add transparent view on top of view2 , view 4 receive gesture event.

change ur entire layout linear layout this. add weight accordingly need.i didnt add weight.this sample code.

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mainview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal">  <view     android:layout_width="220dp"     android:layout_height="wrap_content"     android:background="#000000" />  <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <view         android:layout_width="wrap_content"         android:layout_height="100dp"         android:background="#ffffff" />      <view         android:layout_width="wrap_content"         android:layout_height="100dp"         android:background="#000000" />      <view         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:background="#bbbbbb" />   </linearlayout> 


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -