我有一个布局为 ASCII 格式的 xml 文件:
---------------
| ImageView
--------------
| TextView
--------------
| List...
--------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.some.app"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/MovieCover"
android:layout_width="100dip"
android:layout_height="100dip"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:padding="10dp"
android:id="@+id/TextHeader"
android:background="#000000">
</TextView>
<ListView android:id="@+id/ListView02" android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
当我的 ImageView 和 TextView 占据屏幕的 3/4 以上时,我在显示布局时遇到问题。如何使 ImageView 和 TextView 与正在显示的 ListView 一起滚动?此时,只有 ListView 可以滚动,我希望整个布局都可以滚动,就好像它们是单独的一页一样。
我该怎么做?
最佳答案
您可以使用 <ScrollView>
作为你的布局容器
类似的东西
<ScrollView>
<LinearLayout>
// your layout here
</LinearLayout>
</ScrollView>
之所以需要里面的LinearLayout,是因为ScrollView只能有一个direct child
关于java - 使android listview布局可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4310738/