Learn android <ScrollView rolling view. 18 ..> from scratch, androidscrollview
Because the height of the mobile phone screen is limited, if you want to display multiple groups of information for the components, the ScrollView view can effectively arrange these components, you can automatically perform screen scrolling during browsing. Android. widget. the inheritance structure of the ScrollView class is as follows: java. lang. object upload android. view. view every android. view. viewGroup uses android. widget. frameLayout extends android. widget. scrollViewScrollView features: ScrollView provides a display container that can contain multiple components for scrolling. ScrollView can only contain one component.
XMl file
<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/mylayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > </LinearLayout></ScrollView>
JAVA File Settings
Package com. example. scrollview; import android. app. activity; import android. OS. bundle; import android. view. gravity; import android. view. viewGroup; import android. widget. button; import android. widget. linearLayout; public class MainActivity extends Activity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); LinearLayout layout = new LinearLayout (this); // create the LinearLayout object layout = (LinearLayout) this. findViewById (R. id. mylayout); // instantiate the LinearLayout object // set the width and height of the Button component. layoutParams Params = new LinearLayout. layoutParams (ViewGroup. layoutParams. MATCH_PARENT, ViewGroup. layoutParams. WRAP_CONTENT); for (int I = 0; I <20; I ++) {// set the cycle to create a Button for the system Button = new button (this); Button. setText ("button" + I); // set the title button. setGravity (Gravity. CENTER); // set alignment layout. addView (button, Params); // Add component }}}
Final Effect
Because the ScrollView component is relatively simple, I will not introduce it too much here.
Next prediction: the prompt text: AutoCompleteTextView
ScrollView in android, if it is quickly scrolled to the top, or the scroll bar at the bottom will be displayed for a few seconds and disappear if it disappears in the scroll bar
I have encountered this problem. I used a tablet before. The scrollView scroll bar on the top disappears slowly, so the user experience is particularly poor. In addition, there are many items in the scrollView ...... Imagine it ~
So I was wondering if I could make scrollView's scroll animation disappear quickly ~ The two classes of scrollView and scroller are rewritten ~~ It seems that this is the only thing we can do.
In android, If You Want To scroll the linear layout without scrollview, how can you implement the scrolling view when dragging?
It cannot be implemented, unless you overwrite the linelayout inheritance, but this makes no sense, it is better to use ScrollView