多子滚动视图
Scroll View with multi child
我想制作一个包含多个文本和图像的页面。
但是当我把它们放在滚动视图中时,会说 "ScrollView can only have one child widget. If you want more children, wrap them in a container layout."
我不太明白我应该做什么。
你可以这样做,因为滚动视图只能有一个直接子视图,你必须放置一个视图组,如线性布局、相对布局等。
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/textViewNoInternet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/check_your_internet_connection"
android:textColor="@color/black_transparent_60"
android:textSize="16dp" />
</LinearLayout>
</ScrollView>
我想制作一个包含多个文本和图像的页面。 但是当我把它们放在滚动视图中时,会说 "ScrollView can only have one child widget. If you want more children, wrap them in a container layout." 我不太明白我应该做什么。
你可以这样做,因为滚动视图只能有一个直接子视图,你必须放置一个视图组,如线性布局、相对布局等。
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/textViewNoInternet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/check_your_internet_connection"
android:textColor="@color/black_transparent_60"
android:textSize="16dp" />
</LinearLayout>
</ScrollView>