android - 在 ScrollView 中隐藏滚动条

标签 android android-scrollview

我有一个带有 ScrollView 的应用程序,我不希望滚动条出现在屏幕上。如何在确保滚动仍然有效的同时隐藏 ScrollView 中的滚动条?

enter image description here

最佳答案

在 Java 中添加以下代码:

myScrollView.setVerticalScrollBarEnabled(false);
myScrollView.setHorizontalScrollBarEnabled(false);

在 XML 中为您的 ScrollView 添加以下属性:

android:scrollbars="none"

像这样:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainScroll"
android:scrollbars="none" <!-- line to be added -->
>

关于android - 在 ScrollView 中隐藏滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9494221/

相关文章:

如果项目数量小于屏幕高度,Android LinearLayout 无法正确显示

android - ScrollView 去掉了 LinearLayout 的约束

android - 在 Android 中创建更高级的列表

android - 检测文本框点击 webview 弹出键盘

java - 从 onPostExecute 和 doInBackground 返回 boolean 值

android - ScrollView 在较低版本的 android 中无法正确显示其内容

android - 返回 Android Studio 代码编辑器的快捷方式

Android 菜单项文本和自动大写禁用

android - 自定义 Android ScrollView 的垂直滚动条

android - 如何防止Android ScrollView拦截其父点击事件