无法更改元素在WebView中的位置 [英] Can't change position of elements in webview

查看:159
本文介绍了无法更改元素在WebView中的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个运行良好的简单Webview应用。



现在我必须添加一个后退按钮。





我将其添加为 FrameLayout的子级。我可以更改大小,但是不能更改按钮的位置,它只是位于左上角...对于任何元素来说似乎都是这种情况,我只是使用ImageView尝试过,但我遇到了同样的问题



我也尝试使用 RelativeLayout代替 FrameLayout,如本



不胜感激。

解决方案

我建议使用XML。



将此添加到XML:

 <按钮
android:layout_height = wrap_content
android:id = @ + id / button
android:text = Button
android:layout_width = wrap_content
android:layout_alignParentBottom = true
android:layout_centerHorizo​​ntal = true
>

或将< RelativeLayout> 替换为< android.support.constraint.ConstraintLayout>



阅读此处为什么有效。


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.

解决方案

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.

这篇关于无法更改元素在WebView中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆