Android: Total height of ScrollView
A ScrollView always has 1 child. All you need to do is get the height of the child to determine the total height: int totalHeight = scrollView.getChildAt(0).getHeight();
A ScrollView always has 1 child. All you need to do is get the height of the child to determine the total height: int totalHeight = scrollView.getChildAt(0).getHeight();
If you want a different color fading edge than the background, you have to override the ScrollView’s getSolidColor() method. For example: @Override public int getSolidColor() { return Color.rgb(0x30, 0x30, 0x30); }
Scrolling to the bottom on change I don’t have enough reputation to post a comment yet, so here you go @Dam and @Evert To scroll to the bottom whenever the number of entries in your ForEach changes you can also use the same method with a ScrollViewReader, as mentioned in the answer above, by adding … Read more
Android opens the OnScreenKeyboard automatically if you have an EditText focussed when the Activity starts. You can prevent that by adding following into your Activity’s onCreate method. getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Here is the solution. Found online. I have subclassed WebView and i’m using the requestDisallowInterceptTouchEvent(true); method to allow my webview to handle the scroll event. TouchyWebView.java package com.mypackage.common.custom.android.widgets public class TouchyWebView extends WebView { public TouchyWebView(Context context) { super(context); } public TouchyWebView(Context context, AttributeSet attrs) { super(context, attrs); } public TouchyWebView(Context context, AttributeSet attrs, int … Read more
Something like: public class ObservableWebView extends WebView { private OnScrollChangedCallback mOnScrollChangedCallback; public ObservableWebView(final Context context) { super(context); } public ObservableWebView(final Context context, final AttributeSet attrs) { super(context, attrs); } public ObservableWebView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); } @Override protected void onScrollChanged(final int l, final int t, final int … Read more
Here is what worked for me: <ScrollView android:requiresFadingEdge=”vertical” android:fadingEdgeLength=”150dp”> Or instead in your code, you could do the following: ScrollView scroll = findById(…); scroll.setVerticalFadingEdgeEnabled(true); // Or `scroll.setHorizontalFadingEdgeEnabled(true)`. scroll.setFadingEdgeLength(150);
You can set Listview property as android:scrollbarSize=”10dp” android:scrollbarThumbVertical=”@drawable/custom_scroll_style” Here custom_scroll_style is a xml file under the drawable folder. Lets create the custom_scroll_style.xml. <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <gradient android:angle=”45″ android:endColor=”#FF3401″ android:centerColor=”#ff5c33″ android:startColor=”#FF3401″ /> <corners android:radius=”8dp” /> <size android:width=”4dp”/> <padding android:left=”0.5dp” android:right=”0.5dp” /> </shape> Here I got a Orange color scrollbar. You can use images … Read more
After struggling with that problem for quite some time, I’ve found a solution that seems to work without being too ugly. First, make sure that whatever ViewGroup (directly) contains your EditText has descendantFocusability set to “Before Descendants,” focusable set to “true” and focusableInTouchMode set to “true.” This will not be the ScrollView itself, but the … Read more
This works. Not sure if it’s the best solution or not. // SCROLL VIEW HACK // BOGUS ScrollView view = (ScrollView)findViewById(R.id.scrollView); view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.requestFocusFromTouch(); return false; } });