I have two Views
I am using to arrange some buttons
on the screen. The screen size I am seeing the result on is Moto G in landscape mode - 640dp * 360dp. The problem is - the buttons
are arranging them according to the View with id=center_parent
instead of the the one with id=left_corner
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View android:id="@+id/center_parent"
android:layout_centerInParent="true"
android:layout_width="0dp"
android:layout_height="0dp"/>
<View android:id="@+id/left_corner"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_toLeftOf="@+id/center_parent"
android:layout_marginRight="165dp"
android:layout_above="@+id/center_parent"
android:layout_marginBottom="150dp"
android:layout_alignParentTop="true"/>"
<Button android:id="@+id/btn1"
android:layout_height="20dp"
android:layout_width="20dp"
android:padding="0dp"
android:layout_toRightOf="@+id/left_corner"
android:layout_marginLeft="165dp"
android:layout_below="@+id/left_corner"
android:layout_marginTop="5dp"
android:text="1"
android:textColor="@android:color/black"
android:background="@drawable/star"/>
<Button android:id="@+id/btn2"
android:layout_height="20dp"
android:layout_width="20dp"
android:padding="0dp"
android:layout_toRightOf="@+id/left_corner"
android:layout_marginLeft="330dp"
android:layout_below="@+id/left_corner"
android:layout_marginTop="171dp"
android:text="2"
android:textColor="@android:color/black"
android:background="@drawable/star"/>
<Button android:id="@+id/btn3"
android:layout_height="20dp"
android:layout_width="20dp"
android:padding="0dp"
android:layout_toRightOf="@+id/left_corner"
android:layout_marginLeft="292dp"
android:layout_below="@+id/left_corner"
android:layout_marginTop="171dp"
android:text="3"
android:textColor="@android:color/black"
android:background="@drawable/star"/>
<Button android:id="@+id/btn4"
android:layout_height="20dp"
android:layout_width="20dp"
android:padding="0dp"
android:layout_toRightOf="@+id/left_corner"
android:layout_marginLeft="292dp"
android:layout_below="@+id/left_corner"
android:layout_marginTop="292dp"
android:text="4"
android:textColor="@android:color/black"
android:background="@drawable/star"/>
</RelativeLayout>!
Attached is the image of how it looks on the screen. Even though the arrows show that is measure using left_corner, but is not the case. If I replace left_corner
with center_parent
in the buttons
while arranging the result is the same.
The marked arrow is left_corner
I have found an alternative. So alternative is not what I am looking for. I will love to learn the explanation of this.
Copyright Notice:Content Author:「Abhinav Arora」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/31294199/android-possible-bug-in-android