GridView and ScrollView
GridView
The GridView ScrollView and ListView are almost identical, and the process of creating them is the same as ListView, as you can refer to this post: https://blog.csdn.net/Ace_bb/article/details/104066710
The difference from List'View is that some properties in the layout file are different.
Take a look at the interface layout of the ListView you created earlier:
Property one numColumns
Add the following code to the layout file:
android:numColumns="3"
The interface effect is as follows:
You can modify the number of columns displayed by the control by modifying the number after numColumns.
This feature can be used for photo albums, QQ WeChat's list of emoticons, etc.
numColumns can also be set to be adaptive, with the number of columns set by the size of the control itself.
android:numColumns="auto_fit"
You can also set the width of the control yourself so that the system can adjust the number of columns as follows:
android:columnWidth="50dp"
Distance between controls in property 2 design list
You can set the distance between controls in the list as follows:
android:horizontalSpacing="110dp" android:verticalSpacing="110dp"
The effect after setting is as follows:
ScrollView
ScrollView is used to scroll content areas that are not lists.Only vertical scrolling is supported and only one control can be placed inside the scrollView control, but you can add a LinearLayout and other controls to the LinearLayout.
Code directly here:
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/grid_view_button"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am from ScrollView In Button"/> </LinearLayout> </ScrollView>
The effect is as follows:
Cover this layout to support scrolling.