我正在开发一个带有ImageView的HorizontalScrollView的片段。我想将一个垂直ScrollView实现为父级,将HorizontalScrollView实现为其子级。我该如何实现呢?这是我的.xml文件与HorizontalScrollView: -
<!-- TODO: Update blank fragment layout -->
<SearchView
android:layout_width="fill_parent"
android:layout_height="40dp"
android:id="@+id/searchView"
android:focusable="true"
android:textStyle = "bold|italic"
android:queryHint="@string/search"
android:clickable="true"
android:background="#ffffff" />
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="200dp"
android:scrollbars="horizontal"
android:id="@+id/horizontalScrollView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/LoginFormContainer"
android:orientation="horizontal">
<ImageView
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginRight="2dp"
android:src="@drawable/picture1" />
<ImageView
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:src="@drawable/picture2" />
<ImageView
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:src="@drawable/picture3" />
<ImageView
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:src="@drawable/picture6" />
<ImageView
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:src="@drawable/hospital" />
<ImageView
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginLeft="2dp"
android:src="@drawable/picture7" />
</LinearLayout>
</HorizontalScrollView>
答案 0 :(得分:0)
ScrollView
类用于垂直滚动,所以:
<SearchView
.../>
<ScrollView
.../>
<HorizontalScrollView
.../>
<LinearLayout
.../>
<!-- Multiple views here -->
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
</SearchView>