我的Android应用程序有一个主WebView(从本地资源加载的HTML),我想使用整个屏幕宽度,并能够(垂直)可滚动.所以我在我的布局XML中将WebView包装在ScrollView中,但无论我做什么,我似乎都无法从滚动视图的右侧删除滚动条轨道.更糟糕的是,我似乎无法改变滚动条轨道的背景颜色.
该轨道占用大约10dp左右,这为WebView中的HTML带来了问题.我希望滚动条显示在 Web视图的顶部(iPhone风格,如果您知道我的意思).现在,您可以说"为什么不将您的HTML更改为10px更薄?",这是我的后备解决方案,但我宁愿不必这样做.
这是布局XML的相关片段,你会看到我已经尝试了我能找到的每个android:etc属性:
<ScrollView
android:id="@+id/deal_web_view_holder"
android:layout_below="@id/clock_bar_holder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false"
android:fadingEdge="none"
android:background="#02a7e9"
android:scrollbars="none"
android:scrollbarSize="0dp"
android:paddingRight="0dp"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
android:scrollbarTrackVertical="@drawable/scrollbar_track_vertical" >
<WebView
android:id="@+id/deal_web_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我的目标是平台2.1/API lvl 7,真的只是处理正常大小的显示,mdp,hdp和xhdp.
我在滚动视图中的文本视图中有一个固定的内容.当用户滚动到某个位置时,我想开始一个活动或触发一个Toast.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:id="@+id/scroller">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent" android:id="@+id/story"
android:layout_height="wrap_content" android:text="@string/lorem"
android:gravity="fill" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我的问题是实现受保护的方法onScrollChanged来找出滚动视图的位置.
我找到了这个答案,是否有一个更简单的解决方案,而不是声明一个界面,覆盖滚动视图等,如我发布的链接上所示?
我想使用屏幕的整个宽度并能够使其可滚动。所以我想隐藏 的滚动指示器ScrollView。我怎样才能实现这个目标?