I am trying to put a scroll view to relative layout. Here some part of the layout on the upper and bottom part are to be constant. So I’m using one more layout inside,which has items that need to be scrolled.
But this is not at all happening, also the screen looks very bad with this. I am getting some black space in the bottom of the part where I defined scroll view.
Here is my xml,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:id="@+id/textView1" android:layout_below="@+id/logoTop"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="TextView" android:layout_alignLeft="@+id/logoTop"></TextView>
<ImageView android:src="@drawable/logotop" android:id="@+id/logoTop"
android:layout_alignParentTop="true" android:layout_width="match_parent"
android:scaleType="fitXY" android:layout_height="wrap_content"></ImageView>
<ImageView android:src="@drawable/bardown" android:id="@+id/barDown"
android:layout_width="match_parent" android:scaleType="fitXY"
android:layout_alignParentBottom="true" android:layout_height="40dip">
</ImageView>
<ImageButton
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/btnMap" android:layout_centerInParent="true" android:src="@drawable/map"
android:background="@drawable/mapselector" android:scaleType="fitXY"
android:layout_alignParentBottom="true">
</ImageButton>
<ImageButton
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/utBtn" android:background="@drawable/utilitiesicon"
android:scaleType="fitXY" android:layout_alignTop="@+id/barDown" android:src="@drawable/utilityselector"
android:layout_alignParentRight="true" android:layout_marginRight="10dip"
android:layout_marginTop="3dip">
</ImageButton>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/logoTop"
android:layout_above="@+id/barDown"
android:scrollbars="none">
<RelativeLayout android:id="@+id/tour"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView android:id="@+id/abtHome" android:layout_below="@+id/logoTop"
android:src="@drawable/abouthome" android:scaleType="fitXY"
android:layout_width="match_parent" android:maxWidth="230dip"
android:layout_height="230dip">
</ImageView>
<ListView android:id="@+id/tourList" android:layout_below="@+id/abtHome"
android:scrollbars="none" android:visibility="visible"
android:layout_centerInParent="true" android:layout_above="@+id/barDown"
android:background="#FFFFFF" android:cacheColorHint="#00000000" android:fadingEdge="horizontal"
android:fastScrollEnabled="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:isScrollContainer="false">
</ListView>
<TextView android:id="@+id/tourcity" android:layout_above="@+id/tourList"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:textSize="25dip" android:layout_centerHorizontal="true"
android:editable="false" android:paddingTop="5dip" android:textColor="@color/white"
android:paddingBottom="5dip" android:background="#80000000" android:gravity="center"></TextView>
</RelativeLayout>
</ScrollView>
<ImageButton android:src="@drawable/arrowselector"
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignTop="@+id/barDown"
android:id="@+id/btnBack" android:background="@drawable/arrowleft" android:layout_marginLeft="10dip"
android:layout_marginTop="6dip"></ImageButton>
</RelativeLayout>
Any answer for this?
I solved the issue. It is not good to fit the list view inside scroll view. So what I did is, placed 1 text view and image view in one xml and inflate that in List Adapter.
I placed these 2 fields in another xml say listbox2.xml
Now inside my list adapter, am doing like this
If the position is 0, I am inflating this new xml where I kept the above 2 fields or else it continues in a normal way.
Hope my answer is clear