问题
I developed a simple webview app which is working fine.
Now I have to add a back button.
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
Any help is appreciated.
回答1:
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.
来源:https://stackoverflow.com/questions/57108594/cant-change-position-of-elements-in-webview