I have a fragment with the ListView of items. This ListView is in ScrollView. When I start my app, scrollview adopts the height of one list item. What can I do to expand ScrollView to full screen?
My xml of fragment:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/lvData"
android:layout_width="match_parent"
android:layout_height="fill_parent">
</ListView>
</ScrollView>
</RelativeLayout>
Xml of list item:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="@+id/tv_number"
android:layout_gravity="left|center_vertical"
android:background="@drawable/oval"
android:textAlignment="center"
android:textIsSelectable="false"
android:textStyle="normal|bold"
android:textSize="40sp"
android:layout_marginLeft="20dp"
android:text="@string/number"
android:textColor="#ffffff"
tools:targetApi="jelly_bean_mr1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lesson_name"
android:id="@+id/tv_lesson"
android:layout_gravity="center_horizontal|top"
android:textAlignment="center"
android:textStyle="normal|bold"
android:textSize="20sp"
tools:targetApi="jelly_bean_mr1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Время"
android:id="@+id/tv_time"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/teacher_name"
android:id="@+id/tv_teacher"
android:layout_gravity="center_horizontal|bottom"
android:textStyle="italic" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Кабинет"
android:id="@+id/tv_cab"
android:layout_gravity="right|bottom"
android:layout_marginTop="4dp"
android:layout_marginBottom="17dp" />
</FrameLayout>
Screenshots
https://i.sstatic.net/dSbaB.jpg
https://i.sstatic.net/fsgd3.jpg
http://i.stac k.imgur.com/oVKGJ.jpg
it is a bad idea to encase list view inside a scroll view. you don't need the scroll view the list will scroll on its own and also will Adapt to screen size so just remove the scroll layout and the list view will fill the screen so the layout will be
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/lvData"
android:layout_width="match_parent"
android:layout_height="fill_parent">
</ListView>
</RelativeLayout>