Android: Possible Bug in Android
NickName:Abhinav Arora Ask DateTime:2015-07-08T21:28:42

Android: Possible Bug in Android

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

More about “Android: Possible Bug in Android” related questions

Android: Possible bug in DatePicker?

I have been able to reproduce, in Android emulators 1.5, 1.6, 2.0 and 2.1, the following behaviour: copy text "241299999999999999" from any EditText view; go to any date picker (ex: Date &amp; Time

Show Detail

Android: Possible Bug in Android

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 ...

Show Detail

Is it possible to power an android webview with FireFox for android opensource code?

I created an android webview for my website all was going fine only for me to notice that filechooser was not opening in android versions less than 5.0... After struggling for days, and trying so m...

Show Detail

android adjustViewBounds bug?

When I use android:adjustViewBounds="true" in my imageView xml, it does not function. If I put setAdjustViewBounds(true); in the constructors of my ImageView, it works fine. What is the difference,...

Show Detail

Android 4.0 Custom Dialog - possible Bug?

I am creating a custom Dialog with the following style: &lt;style name="FullHeightDialog" parent="android:style/Theme.Dialog"&gt; &lt;item name="android:windowNoTitle"&gt;true&lt;/item&

Show Detail

Android SurfaceView bug

I have encountered the nasty Android SurfaceView behavior: When you leave an Activity with SurfaceView and quickly go back, the previous content of SurfaceView doesn't disappear and is displayed un...

Show Detail

Android viewflipper bug

When I am using viewflipper using a button click it transits from right to left. But the view moves a little inside and again bounces back. Imagine something like a spring effect. I suppose this is...

Show Detail

Is that is a bug with CheckBox in android?

I am using 2.1 android version. I was creating a check box and I saw something Strange with checkbox. When I put android:padding="5dp" the check box shown as But the text should be shown next to

Show Detail

Understanding Bug Report in Android Development

I am trying to understand Bug Reporting in Android I successfully Captured the bug reports as mention in Android Docs from my Android device But don't know how to understand these files, log messa...

Show Detail

Android Save Log Or Bug Tracking

I have developed application in Android and submit to client for testing feature now at that time error are generated now I want to track that error. I have use android Log.e(string,string) method ...

Show Detail