Android to develop high-level components

Source: Internet
Author: User

Android Development High-level components--scrollview (rolling video)
1, the height of the mobile screen is limited, when the need to display multi-group information, ScrollView Vision can reasonably arrange these components, browsing can be self-scrolling display. ScrollView is a rolling screen, as long as you need to add a rolling screen to the ScrollView. ScrollView supports vertical rolling, Horizontalscrollview supports horizontal rolling.

2. The ScrollView structure is as follows:
Java.lang.Object
Android.view.View
Android.view.ViewGroup
Android.widget.FrameLayout
Android.widget.ScrollView

3. ScrollView components can be set in the code, or in the XML layout file in the setup, It is used in a form similar to that of the Www.android5.online manager, where the layout manager can contain multiple components, and there can be only one group in the rolling image, where the components of the extra screen height can be contained.

4. Create a new 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"
Android:id= "@+id/scroll" >

<linearlayout
Android:id= "@+id/layout"
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent" >

</LinearLayout>

</ScrollView>

5. Modify the Mainactivity.java file
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.view.ViewGroup;
Import Android.widget.LinearLayout;
Import Android.widget.TextView;

/**
* Created by Xiao on 2016/12/26.
*/
public class Mainactivity extends Activity {

Private String scrolldata[] = {"Information Academy", "Mechanical Academy", "Computer Science Institute", "News Academy", "Chemical Institute",
"American Academy", "Computer Academy", "News Academy", "Chemical Academy", "Art Academy", "Physical Education Academy", "Music Academy",
"Economic Management Academy", "Nanhu Academy", "Physics and Electronics Academy", "Electrical Academy", "Law School", "Foreign Language Academy",
"Technology", "library", "Teaching", "Network Center", "academic work", "financial"};

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.scrollview_xml);

LinearLayout layout = (linearlayout) Findviewbyid (r.id.layout);
Linearlayout.layoutparams params = new Linearlayout.layoutparams (
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);

for (int i = 0; i < scrolldata.length; i++) {
TextView msg = new TextView (this);
Msg.settextsize (20);
Msg.settext (Scrolldata[i]);
Layout.addview (msg, params);
}
}
}

6, generally do not add event monitoring in ScrollView, if a group needs to respond to events, generally use the ListView components. (Android Tutorial Network http://www.android5.online/Android/androidxt/androidkf/201702/69928.html)

Android to develop high-level components

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.