我的布局文件中定义了一个web视图,其下有一些固定高度的按钮。
< XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:fadingEdge =无>
<的WebView
机器人:ID =@ + ID / web视图
机器人:layout_width =FILL_PARENT
机器人:layout_height =0dp
机器人:layout_weight =1.0/>
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =60dp
机器人:填充=8DP>
<按钮
机器人:文本=拒绝
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1.0>
< /按钮>
<按钮
机器人:文本=接受
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1.0>
< /按钮>
< / LinearLayout中>
< / LinearLayout中>
我想添加填充周围的WebView,因为此刻的文本运行直到用户界面的边缘。
我尝试添加安卓填充=8DP
的web视图,但不会添加填充。我也尝试以下属性来和paddingRight过,但他们也不能工作。
借助的WebView API文档确认从View,它支持的android:padding属性,所以我很惊讶这没有奏效。
有谁知道这是一个已知的问题,还是我的布局XML的一些互动,我不是理解?
仅供参考,我的解决方法是把一个额外的LinearLayout各地的WebView,并填充添加到代替:
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =0dp
机器人:layout_weight =1.0
机器人:填充=8DP>
<的WebView
机器人:ID =@ + ID / web视图
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT/>
< / LinearLayout中>
解决方案
web视图在填充实现中的错误。在web视图不会垫的实际网页,但会垫滚动条设置填充。这只是部分工作正常。 您的解决方案是实现填充了的WebView的最佳方式。
![photoshop 里 怎么添加填充材质](https://p.xsw88.cn/allimgs/daicuo/20230904/8447.png)
My layout file defines a WebView, underneath which there are some fixed height buttons.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="none">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:padding="8dp">
<Button
android:text="Decline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0">
</Button>
<Button
android:text="Accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0">
</Button>
</LinearLayout>
</LinearLayout>
I'm trying to add padding around the WebView, as at the moment the text runs right up to the edge of the UI.
I tried adding android:padding="8dp"
to the WebView, but no padding was added. I also tried paddingLeft and paddingRight too, but they didn't work either.
The WebView API docs confirm it inherits from View, which supports the android:padding attribute, so I'm surprised this didn't work.
Does anybody know if this is a known issue, or some interaction of my layout XML that I'm not understanding?
FYI, my workaround was to put an extra LinearLayout around the WebView, and add the padding to that instead:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:padding="8dp">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
解决方案
The WebView has a bug in the padding implementation. Setting a padding on a webview won't pad the actual web page, but WILL pad the scrollbars. It's only partially working as expected. Your solution is the best way to achieve 'padding' for a WebView.
相关推荐
最新文章