android - 防止在 webview 中移动按钮
问题描述
我在 webview 上有一个按钮,我想问当我沿着 webview 向下滚动时如何防止移动该按钮?我使用相对布局
我这样做了,但我正在寻找更好的解决方案
webView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollX == 0 && scrollY == 0 ){
myBtn.setVisibility(View.VISIBLE);
}else{
myBtn.setVisibility(View.GONE);
}
}
});
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFD0">
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</WebView>
<Button
android:id="@+id/myBtn"
android:backgroundTint="#172632"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:text="Scanner"
/>
</RelativeLayout>
解决方案
推荐阅读
- gruntjs - 未找到“browserSync”目标
- typescript - Karma、Webpack 和 Typescript:TS2307:找不到模块“log4js”或其相应的类型声明
- android - Android EditText:仅启用滚动但停止点击
- pandas - Pandas 列在条件下合并
- javascript - 如何在 chrome 扩展弹出窗口中使用 chrome 存储
- java - 无法随机化 java 字符串数组
- c# - 将段落从另一个线程添加到 RichTextBox 时 C# 程序崩溃
- swift - 返回可编码数组的结果
- javascript - 在按钮单击时调用 PHP
- ruby-on-rails - 如何在 Azure 上运行 Sidekiq?