[android] Remove scroll bar track from ScrollView in Android

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.

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.

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>

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

This question is related to android android-layout scrollview android-scrollbar

The answer is


By using below, solved the problem

android:scrollbarThumbVertical="@null"

These solutions Failed in my case with Relative Layout and If KeyBoard is Open android:scrollbars="none" & android:scrollbarStyle="insideOverlay" also not working.

toolbar is gone, my done button is gone.

not Working

This one is Working for me

myScrollView.setVerticalScrollBarEnabled(false);

Solved my problem by adding this to my ListView:

android:scrollbars="none"

try this is your activity onCreate:

ScrollView sView = (ScrollView)findViewById(R.id.deal_web_view_holder);
// Hide the Scollbar
sView.setVerticalScrollBarEnabled(false);
sView.setHorizontalScrollBarEnabled(false);

http://developer.android.com/reference/android/view/View.html#setVerticalScrollBarEnabled%28boolean%29


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"

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-layout

How to check if a key exists in Json Object and get its value How to center the elements in ConstraintLayout Android - how to make a scrollable constraintlayout? Add ripple effect to my button with button background color? This view is not constrained vertically. At runtime it will jump to the left unless you add a vertical constraint Is it possible to put a ConstraintLayout inside a ScrollView? Differences between ConstraintLayout and RelativeLayout How to remove title bar from the android activity? How to have EditText with border in Android Lollipop Android: ScrollView vs NestedScrollView

Examples related to scrollview

How to scroll page in flutter How do I scroll the UIScrollView when the keyboard appears? Can I have onScrollListener for a ScrollView? Is there a way to programmatically scroll a scroll view to a specific edit text? How to use ScrollView in Android? Call removeView() on the child's parent first Can I scroll a ScrollView programmatically in Android? Remove scroll bar track from ScrollView in Android ListView inside ScrollView is not scrolling on Android How to always show scrollbar

Examples related to android-scrollbar

Remove scroll bar track from ScrollView in Android Disable scrolling in webview?