当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Scrolling for more items than will fit on screen

问题描述:

I have a display screen that has more items than will fit. I would like to make it scrollable

but cant figure out the XML. I have below code

<?xml version="1.0" encoding="utf-8"?>

<ScrollView android:id="@+id/scrollView1"

android:layout_width="fill_parent" android:layout_height="fill_parent"

xmlns:android="http://schemas.android.com/apk/res/android"

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical" >

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Auto Settings"

android:textAppearance="?android:attr/textAppearanceLarge" />

//more items

</LinearLayout>

</ScrollView>

It throws an error at the first linear layout. What am I doing wrong?

网友答案:

It's plain XML syntax error. Terminate your ScrollView tag with >.

网友答案:

You can try this code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg_1"
    android:orientation="vertical" >

  <ScrollView
    android:id="@+id/ScrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_margin="10dp" >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" >

        <ImageButton android:id="@+id/imageUser"
            android:layout_width="108dip"
            android:layout_height="81dip"
            android:layout_marginTop="10dp"
            android:background="@drawable/bg_profile" />

        // more items
    </RelativeLayout>
  </ScrollView>
</RelativeLayout>
分享给朋友:
您可能感兴趣的文章:
随机阅读: