Android Java Buttons coordinates



I want to resize buttons if the screen is big . So I have done it using this method . I got screen size and put button width screenWidth/4 . But now I can't put buttons position . I used relative layout and I put their position from xml but when I change their sizes the are lying each on other at 0,0 position. tihs is on nexus S this is on nexus 10


Here is XML



<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pink"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.vahe_muradyan.yourquote.MainActivity" >

<Button
android:id="@+id/openCamera"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="71dp"
android:background="@drawable/roundbuttom"
android:text="@string/camera" />

<Button
android:id="@+id/openGallery"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignLeft="@+id/openDefaults"
android:layout_below="@+id/openDefaults"
android:layout_marginTop="43dp"
android:background="@drawable/roundbuttom"
android:text="@string/gallery" />

<Button
android:id="@+id/openDefaults"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignLeft="@+id/openCamera"
android:layout_centerVertical="true"
android:background="@drawable/roundbuttom"
android:text="@string/defaults" />

</RelativeLayout>


I have upploaded images on Nexus S and nexus 10 .


No comments:

Post a Comment