从滚动型Android中移除滚动条轨道 [英] Remove scroll bar track from ScrollView in Android

查看:342
本文介绍了从滚动型Android中移除滚动条轨道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用程序有一个主要的WebView(HTML从本地资源加载),我想使用屏幕的整个宽度,能够使(垂直)滚动。所以我裹在滚动型web视图在我的布局XML,但无论我做什么,我似乎无法能够从右侧的滚动视图中删除滚动条轨道。更糟糕的是,我似乎无法能够改变滚动条轨道的背景颜色。

My Android app has a main WebView (HTML loaded from a local resource) which I want to use the entire width of the screen and be able to make (vertically) scrollable. So I've wrapped the WebView in a ScrollView in my layout XML, but no matter what I do I can't seem to be able to remove the scroll bar track from the right side of the scroll view. Even worse, I can't seem to be able to change the background colour of the scroll bar track.

这条赛道占地约10dp的左右,这是建立在web视图的HTML问题。我想出现滚动条的在上面的Web视图的(iPhone的风格,如果你知道我的意思)。现在,你可以说:你为什么不改变你的HTML是10px的变瘦了?,这是我的备用解决方案,但我宁愿不用。

The track takes up about 10dp's or so, which is creating problems for the HTML in the WebView. I'd like the scroll bar to appear on top of the web view (iPhone style, if you know what I mean). Now, you could say "why don't you change your HTML to be 10px thinner?", which is my fallback solution, but I'd much rather not have to.

下面的布局XML的相关片段,你会看到我已经试过每一个Android:等属性我能找到的:

Here's the relevant snippet of layout XML, you'll see I've tried every android:etc attribute I could find:

<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>

我针对平台2.1 / API LVL 7,真的只是应付正常大小的显示器,MDP,HDP和xhdp。

I'm targeting platform 2.1 / API lvl 7, really just dealing with normal size displays, mdp, hdp and xhdp.

推荐答案

我有点困惑,为什么你把一个的WebView 滚动型摆在首位。 A 的WebView 有它自己内置的滚动系统。

I'm a little confused why you are putting a WebView into a ScrollView in the first place. A WebView has it's own built-in scrolling system.

至于你的实际问题,如果你想在滚动条来显示在上面,你可以使用

Regarding your actual question, if you want the Scrollbar to show up on top, you can use

view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY) or   
android:scrollbarStyle="insideOverlay"

这篇关于从滚动型Android中移除滚动条轨道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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