Can't change position of elements in webview

雨燕双飞 提交于 2020-01-06 04:47:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!