0

I developed a simple webview app which is working fine.

Now I have to add a back button.

enter image description here

I added it as a child of "FrameLayout". I can change the size, but I can't change the position of the button, it just sits at the top left... This seems to be the case for any element, I just tried it with ImageView and I have the same problems with it.

I also tried to use "RelativeLayout" instead of "FrameLayout" as adviced in this answer, but it makes no difference

enter image description here

Any help is appreciated.

Black
  • 18,150
  • 39
  • 158
  • 271

1 Answers1

2

I recommend to use XML.

Add this to your XML:

<Button
        android:layout_height="wrap_content"
        android:id="@+id/button"
        android:text="Button" 
        android:layout_width="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
    >

Or replace <RelativeLayout> with <android.support.constraint.ConstraintLayout>.

Read here why it works.

Jakob
  • 1,858
  • 2
  • 15
  • 26