Remove scroll bar track from ScrollView in Android - 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.

To remove a scrollbar from a view (and its subclass) via xml:
android:scrollbars="none"
http://developer.android.com/reference/android/view/View.html#attr_android:scrollbars

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"

Solved my problem by adding this to my ListView:
android:scrollbars="none"

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.
This one is Working for me
myScrollView.setVerticalScrollBarEnabled(false);

By using below, solved the problem
android:scrollbarThumbVertical="#null"

Related

Android Webview examping inside of scrollview / cannot scroll

Problem:
The scroll bar shows up for a SPLIT second then it's gone. I can change the ScrollView's height to 100dp and in the small little box I can scroll.
In the Android Device Monitor I can see that both elements are 1920 in height. It seems as though the webview is somehow pushing everything else to break their match_parent rules because they are acting more like wrap_content. What's going on here?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="#+id/speakerBioWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="1000dp"></WebView>
</ScrollView>
</LinearLayout>
Solution
I noticed that Android Studio was voicing a faint warning about my setup. The warning showed as a faint red line underneath the WebView's layout_height attribute. I changed the it to match_parent and took the outside ScrollView off.
This really was an error is oversight because the warning was not getting my attention at all. Make sure you look at all your compiler / IDE warnings to see if there are any helpful notices.
Not sure why you want a scroll view around a WebView as
WebView has its own scroll bar.

Android fixed background image in scrollview while scrolling

I have a situation where I need a scrollview to have a background image that shouldn't scroll along with it's parent when moving. Before any of you suggest me the links for setting background image and this that, I have already tried and it's not working.
The whole story goes like: I have an activity with fragments which have their own backgrounds with some input fields. When focusing over input fields, keyboard appears and background image squeezes. For that I put an image on background of scrollview that fixed my issue of squeezing background but raised another concern that background Image should stay static while scrolling the parent scrollview.
The second solution any of you may suggest is setting background of my activity rather playing with scrollview. That's right, but for that I had to make a style element with background of theme which appears odd while transitioning different fragments plus it adds overhead when I have a lot of code and fragments to move forward and back.
That's the point where I am stuck. I have gone through links below, if you just need to know that I tried it or not.
link1
link2
link3
... and so on
below is the layout I am using for my fragments (it's all being done programmatically)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/top_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/backgroundView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/app_name"
android:scaleType="fitXY" />
<LinearLayout
android:id="#+id/parent_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</ScrollView>
</LinearLayout>
So if you guys have any better solution keeping in mind the situation I have, will be warmly welcomed. Thank you
None of the above works for me with some reason but this things works.
getWindow().setBackgroundDrawableResource(R.mipmap.img_reg_bg);
put it in oncreate method hope it will help.
If I guess right you try to fix your hotfix to get it working propperly. If I'm right you sould go back to scratch and do it without your scrollview.
If you have a look at following Link:
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
you'll see softkeyboard mode can be adjusted. "adjustPan" should solve your problem.
"adjustPan"
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
Add someimgage to your drawable folderes, like drawable-mdpi, drawable-hdpi.
In your LinearLayout "#+id/top_layout" add attribute:
android:background="#drawable/someimage"

How can we remove default Android Device colour

I am going on with the scroll action in my Android Device if i scroll any thing in the device after it reaches the end point in top and bottom if even we scroll it shows some colours for different device eg:(samsung it shows blue light).
Here i attached a screenshot below:
How can we remove it or if no chance can we change the color
Usually we will use ScrollView,Listview etc to scroll the view should go on with XML or progrmatically.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollingCache="false"
android:fadingEdge="none" >
TRIED
android:cacheColorHint="#00000000"
android:scrollingCache="false"
list.setCacheColorHint(Color.TRANSPARENT);
android:fadingEdge="none"
listView.setVerticalFadingEdgeEnabled(false);
android:overScrollMode="never"
But no change can any one help me to fix this issue.
this effect is named overscroll
listView.setOverscrollFooter(new ColorDrawable(Color.RED));
listView.setOverscrollHeader(new ColorDrawable(Color.RED));
be awared that some devices ignores this params, example here
I don't know how to completely disable the overflow in the ScrollView, but I have come across a library that you can use so as to change your overflow color.
LINK:https://github.com/AndroidAlliance/EdgeEffectOverride
Here is the solution which helped me to solve
Custom overscroll glow/edge color for ListView?
for the user Menny
referred link:http://evendanan.net/android/branding/2013/12/09/branding-edge-effect/
Hope this help's you

Changing the color of over scroll in scrollview in android

I have a small problem with my scroll view. Whenever a scroll view has over scrolled, it shows a yellow gradient (in my device, it may vary for other devices) at edges of scroll view. It can be eliminated by setting attribute as below in android 2.3 and above.
android:overScrollMode="never"
Now i want to change the default color to some other. How to achieve this.
Please help me regarding this. Any help will be appreciated.
You should use the following attributes on your ListView :
<ListView
...
android:overScrollHeader="#drawable/header"
android:overScrollFooter="#drawable/footer"/>
You could also set them programatically using setOverscrollFooter(Drawable d) and setOverscrollHeader(Drawable d).
This EdgeEffectOverride library works nicely for all scroll-type views: https://github.com/AndroidAlliance/EdgeEffectOverride
E.g.
<uk.co.androidalliance.edgeeffectoverride.EdgeEffectScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
...
app:edgeeffect_color="#color/red"
/>
And
EdgeEffectScrollView gridView = (EdgeEffectScrollView) root.findViewById(R.id.myscroll);
gridView.setEdgeEffectColor(Color.RED);

Android: problem scrolling my activity including a WebView

I included a WebView in my activity and load some Javascript in it which is then going to get data from an external website.
This works and displays fine but the problem is that my activity doesn't scroll when the WebView is done loading so I can't see the bottom of the WebView such as all the other Views I put below this. Any idea of how I should handle this?
Cheers.
Are you using scrollview in your layout? Try that and see if that helps.
Here is a link to the developer page
This works and displays fine but the problem is that my activity doesn't scroll when the WebView is done loading so I can't see the bottom of the WebView such as all the other Views I put below this.
You need to change your layout such that the "other Views I put below this" will be on the screen, and the WebView simply takes up the remaining space.
For example, here is a layout showing a WebView with a Button:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView android:id="#+id/webkit"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
/>
<Button android:id="#+id/helpcast"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="View Helpcast"
/>
</LinearLayout>
Because the WebView is set up with a 0px height but a weight of 1, and because the Button specifies no weight, the WebView will fill all space left over after the Button is on-screen. The WebView content will scroll inside the WebView itself, if needed, based upon whatever Web page you load in there.

Categories

Resources