I have an xml file that has the layout in ASCII form:
---------------
| 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">
<ImageV开发者_JAVA百科iew
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>
I'm having a problem displaying the layout when my ImageView and TextView takes up more than 3/4 of the screen. How do I make ImageView and TextView scrollable with the ListView that is being displayed? At this point of time, only the ListView to be scrolled and I want the entire layout to be scrollable as though they are one page on its own.
How can I do that?
You can use <ScrollView>
as your layout container
something along the line of
<ScrollView>
<LinearLayout>
// your layout here
</LinearLayout>
</ScrollView>
the reason why we need the LinearLayout inside is that ScrollView can only have one direct child
Butter to use two LinearLayout with layoutweight="1"
and put ScrollView in one and listview in other
<LinearLayout android:layout_weight="1"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- scroll view content -->
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout android:layout_weight="1"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<ListView android:id="@+id/ListView02" android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
ListView has addtoHeader and addtoFooter function. Make a separate layout and add it into header of ListView . In your case make a relative layout of imageview and textview and add it to the header of listview. The entire page will start scrolling.
How about putting the ImageView and TextView in a layout and putting this layout inside a ScrollView.?
精彩评论