Android ScrollView can only add one child control problem solving method _android

Source: Internet
Author: User

The example in this article tells you that the Android ScrollView can only add one child control problem-solving method. Share to everyone for your reference, specific as follows:

There's a section of code here

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/apk/" Res/android "
  android:layout_width=" fill_parent "
  android:layout_height=" fill_parent "
  android:o" rientation= "vertical" >
  <scrollview
    android:layout_width= "fill_parent"
    android:layout_height= "Fill_parent" >
    <button
      android:layout_width= "fill_parent"
      android:layout_height= "WRAP_" Content "/>
    <button
      android:layout_width=" fill_parent "
      android:layout_height=" wrap_content "/>
    <button
      android:layout_width=" fill_parent "android:layout_height=" wrap_content "/>"
  </ScrollView>
</LinearLayout>

A scrollview inside Add three button, perhaps you think that there is no problem, then we run a look at

An exception has occurred

Obviously, the anomaly tells us that ScrollView can host only one direct child

Since we can only hold a direct child control, we could accommodate multiple indirect child controls, and then set a layer of linearlayout directly outside the child controls.

 <?xml version= "1.0" encoding= "Utf-8"?> <linearlayout "xmlns:android="
  Schemas.android.com/apk/res/android "android:layout_width=" fill_parent "android:layout_height=" Fill_parent " android:orientation= "vertical" > <scrollview android:layout_width= "fill_parent" android:layout_height= "fil"
      L_parent "> <linearlayout android:layout_width=" fill_parent "android:layout_height=" Fill_parent " android:orientation= "vertical" > <button android:layout_width= "fill_parent" Android:layout_ height= "Wrap_content"/> <button android:layout_width= "Fill_parent" android:layout_height= P_content "/> <button android:layout_width= fill_parent" android:layout_height= "Wrap_content" /> </LinearLayout> </ScrollView> </LinearLayout> 

For more information on Android-related content readers can view the site topics: "Android Development Introduction and Advanced Course", "Android Multimedia operating skills Summary (audio, video, recording, etc.)", "Android Basic Components Usage Summary", " Android View tips Summary, Android layout layout tips and a summary of Android controls usage

I hope this article will help you with the Android program.

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.