ScrollView is not scrolling overflowed layout - android

I have a scroll view containing one child layout(linear layout) and that child contains a relative layout and a linear layout. Relative layout and linear layout shares half-half screen. Linear layout has buttons added to it dynamically.
Now problem arises as scroll view does not scroll buttons while it scrolls relative layout and linear layout.
<ScrollView>
<LinearLayout>
<RelativeLayout>
</RelativeLayout>
<LinearLayout>
->Dynamically adding buttons here
</LinearLayout>
</LinearLayout>
</ScrollView>
I want those buttons scroll with scrollview
For reference my xml code is :-
<LinearLayout 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"
android:background="#color/whitecolor"
android:orientation="vertical"
>
<ScrollView
android:id="#+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RelativeLayout
android:
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bluecolor"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/stauslinearlayout"
android:layout_marginBottom="8dp"
android:padding="5dp"
android:gravity="center"
android:textColor="#color/whitecolor"
android:text="#string/app_name"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="#color/bluecolor"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/edit_text_custom"
android:singleLine="true"
android:hint="#string/status"
android:textColor="#000"
android:textColorHint="#5222"
android:padding="7dp"
android:maxLength="50"
android:cursorVisible="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:drawableLeft="#android:drawable/ic_input_add"
android:ems="10"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|center_horizontal"
android:gravity="center"
android:layout_weight="0"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:padding="5dp"
android:text="#string/statusnumber"
android:background="#drawable/edit_text_custom"
/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/whitecolor"
android:text="abcdfrg"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>

AFAIK, If you want to divide screen in to same two sizes, you have to take another scrollView in bottom view, like below example...
<LinearLayout 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"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/darker_gray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/stauslinearlayout"
android:layout_marginBottom="8dp"
android:gravity="center"
android:padding="5dp"
android:text="#string/app_name"
android:textColor="#android:color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:color/darker_gray"
android:orientation="horizontal" >
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:cursorVisible="true"
android:drawableLeft="#android:drawable/ic_input_add"
android:ems="10"
android:hint="status"
android:maxLength="50"
android:padding="7dp"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#5222" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
android:text="statusnumber" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:text="abcdfrg" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</ScrollView>
</LinearLayout>
and if you don't want to take another scrollView, then you have to give wrap_contant to bottom linear-layout.
<LinearLayout 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"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/darker_gray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/stauslinearlayout"
android:layout_marginBottom="8dp"
android:gravity="center"
android:padding="5dp"
android:text="#string/app_name"
android:textColor="#android:color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:color/darker_gray"
android:orientation="horizontal" >
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:cursorVisible="true"
android:drawableLeft="#android:drawable/ic_input_add"
android:ems="10"
android:hint="status"
android:maxLength="50"
android:padding="7dp"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#5222" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
android:text="statusnumber" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:text="abcdfrg" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
choice goes to your requirement.
if any problem yet, then plz ask... :-)

Related

How to set the max height of a list view

I have 3 vertical parts on the screen:
Some texts
Listview
Some more text fields
I don't understand why when there are more elements in the listview, it takes the whole screen to the bottom without leaving place for the 3rd part and makes this 3rd part unreachable and not visible.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.transport.ScreenDelivery">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:gravity="center_vertical"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_customer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="#+id/listView_pallets"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textView_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
here you go
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.transport.ScreenDelivery">
<LinearLayout
android:id="#+id/bottom_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_expectedSum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Очаквана сума"
android:textSize="16sp"
tools:text="Очаквана сума" />
<TextView
android:id="#+id/textView_expectedSumNum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="-"
android:textSize="16sp"
tools:text="-" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Подпис"
android:textSize="16sp"
tools:text="Подпис" />
<TextView
android:id="#+id/textView_signatureField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_returnSum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Сума за връщане"
android:textSize="16sp"
tools:text="Сума за връщане" />
<TextView
android:id="#+id/_returnSumField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_remarks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Бележка"
android:textSize="16sp"
tools:text="Бележка" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical">
<Spinner
android:id="#+id/spinner_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/btn_dropdown"
android:spinnerMode="dropdown" />
<EditText
android:id="#+id/editText_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint=""
android:inputType="text"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_image"
android:layout_width="269dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Снимка"
android:textSize="16sp"
tools:text="Снимка" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="horizontal">
<Button
android:id="#+id/button_takePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="150dp"
android:onClick="takePhoto"
android:text="Снимай"
tools:text="Снимай" />
<ImageView
android:id="#+id/imageView_deliveryPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Снимка на доставката"
android:maxHeight="200dp"
android:maxWidth="200dp"
android:minHeight="50dp"
android:minWidth="50dp"
app:srcCompat="?android:attr/alertDialogIcon" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal">
<Button
android:id="#+id/button_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Запази"
tools:text="Запази" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/top_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_customer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Клиент"
android:textSize="20sp"
tools:text="Клиент" />
<TextView
android:id="#+id/textView_palletCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Брой палета"
android:textSize="20sp"
tools:text="Брой палета" />
<TextView
android:id="#+id/textView_palletCountNum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="-"
android:textSize="20sp"
tools:text="-" />
</LinearLayout>
<ListView
android:id="#+id/listView_pallets"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottom_layout"
android:layout_below="#id/top_layout" />
</RelativeLayout>
I am sure you can find a solution only using the constraint layout and removing your linear layouts altogether but I don't know enough about ConstraintLayout to help you there. However you can give weights to the elements inside your Outermost LinearLayout. e.g. assign android:weightSum="3" to your outermost LinearLayout and then android:layout_weight="1" to the inner elements (in your case the other LinearLayouts)

My ListView is hiding behind my parent layout when visibility is set to View.GONE

I am trying to set my list view when I click on image, it should be hidden or shown but the problem is that when I inflate my list view in my activity, it is hiding behind and not taking complete space. When I perform on click event it opens behind the parent layout.
SNAPSHOT
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical"
tools:context="com.bitblue.dextronewproject.Avtivity.ReportActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/main_linear_layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Fees History"
android:textSize="20sp"
android:typeface="monospace" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="5dp"
android:background="#color/studentlogin" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Receipt"
android:typeface="monospace" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:typeface="monospace" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Date"
android:typeface="monospace" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_2"
android:layout_below="#+id/ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TableLayout
android:id="#+id/r_tablelayoutRAD"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
</TableLayout>
<ImageView
android:id="#+id/drop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5.5"
android:src="#drawable/ic_drop_down_round_button" />
</LinearLayout>
<ListView
android:layout_below="#id/ll_2"
android:id="#+id/lisstview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</ListView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Unpaid"
android:textSize="20sp"
android:typeface="monospace" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="30dp"
android:text="Type"
android:textSize="15dp"
android:typeface="monospace" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="30dp"
android:text="Amount"
android:textSize="15dp"
android:typeface="monospace" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="5dp"
android:background="#color/studentlogin" />
<ListView
android:layout_width="match_parent"
android:id="#+id/un_paid_list_view"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
</RelativeLayout>
Your effort is appreciable.Thanks in andvance
Your parent layouts are not matching. You have used layout_below in LinearlLayout where the parent is not RelativeLayout. Check the hierarchy of the layouts in your layout.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical"
tools:context="com.bitblue.dextronewproject.Avtivity.ReportActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Fees History"
android:textSize="20sp"
android:typeface="monospace"
android:id="#+id/textView1"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="5dp"
android:background="#color/studentlogin"
android:layout_below="#+id/textView1"
android:id="#+id/view1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/view1"
android:id="#+id/ll1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Receipt"
android:typeface="monospace" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:typeface="monospace" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Date"
android:typeface="monospace" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_2"
android:layout_below="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TableLayout
android:id="#+id/r_tablelayoutRAD"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
</TableLayout>
<ImageView
android:id="#+id/drop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5.5"
android:src="#drawable/ic_drop_down_round_button" />
</LinearLayout>
<ListView
android:layout_below="#+id/ll_2"
android:id="#+id/lisstview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Unpaid"
android:textSize="20sp"
android:typeface="monospace"
android:layout_below="#+id/lisstview"
android:id="#+id/textView2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/textView2"
android:id="#+id/ll3">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="30dp"
android:text="Type"
android:textSize="15dp"
android:typeface="monospace" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="30dp"
android:text="Amount"
android:textSize="15dp"
android:typeface="monospace" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="5dp"
android:background="#color/studentlogin"
android:layout_below="#+id/ll3"
android:id="#+id/view3"/>
<ListView
android:layout_width="match_parent"
android:id="#+id/un_paid_list_view"
android:layout_height="wrap_content"
android:layout_below="#+id/ll3"/>

Linear layout below the ListView, Some portions not visible?

I have a problem with LinearLayout which is below the listview. I tried to give the listview weight and layout above, set the layout_height to 0dp but nothing wotked.
Here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
when ListView fills the screen, I cannot see the buttons below to it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30" />
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="90">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Your layout edited by adding layout weights. Please check.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="0.3"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
You should try List View with Layout having weight.
Sample Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
/>
</LinearLayout>
In this your height is fixed for listview. Assuming that you can use list view as srollable in particular height.
<?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">
<LinearLayout
android:id="#+id/topLayout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alignParentTop="true"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:alignParentBottom="true"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/topLayout"
android:layout_above="#+id/bottomLayout">
</ListView>
</RelativeLayout>
Have edited your code. Try this.
Here in this I have used RelativeLayout, so that we use android:alignParentBottom="true" for bottom layout which makes the layout in fix in bottom. Simillarly we can do for top layout using android:alignParentBottom="true". Now coming to ListView, which we need to place between top and bottom layout I have used the following code to achieve it
android:layout_below="#+id/topLayout"
android:layout_above="#+id/bottomLayout"
This makes the ListView to stick in between the top and bottom layout.
Hope this is helpful:)
Change as below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Keyboard shrinking EditText

I have three EditText in my layout. When i click on any of them then it shrinks my layout and the second layout is barely visible. I want that when i click on second layout ("Dear Parents"), keyboard should overlap the last edittext (teachers name) and when i click on last edittext then it should appear above keyboard.
Here are the screenshots
and here is the code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/actionbar_title_color"
android:orientation="vertical">
<include
android:id="#+id/include"
layout="#layout/toolbar" />
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="25dp"
card_view:cardElevation="10sp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#drawable/filebinder" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="14"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="vertical">
<TextView
android:id="#+id/dateDiary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="30 July"
android:textColor="#03a9f4"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#03a9f4" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/diarybookmark" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<EditText
android:id="#+id/diaryHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:ems="5"
android:fontFamily="sans-serif"
android:hint="Diary Heading"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="18sp" />
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/diaryTeacherName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:fontFamily="sans-serif"
android:hint="Teacher\'s Name..."
android:textSize="16sp" />
<at.markushi.ui.CircleButton
android:id="#+id/addDiaryEntry"
android:layout_width="74dip"
android:layout_height="74dip"
android:layout_gravity="right"
android:src="#drawable/ic_action_tick"
app:cb_color="#color/actionbar_title_color"
app:cb_pressedRingWidth="8dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:id="#+id/diaryContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/addDiaryEntry"
android:layout_alignLeft="#+id/scrollView"
android:layout_alignStart="#+id/scrollView"
android:layout_alignTop="#+id/scrollView"
android:fontFamily="sans-serif"
android:gravity="top"
android:hint="Enter Diary Note...\n\n\n\n"
android:text="Dear Parents,"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
and here is my manifest
<activity
android:name=".DiaryEntry.DiaryEntryTeacherActivity"
android:label="DiaryEntry"
android:windowSoftInputMode="adjustResize"
android:theme="#style/AppTheme.NoActionBar"></activity>
You need to use ScrollView as;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/actionbar_title_color"
android:orientation="vertical">
<include
android:id="#+id/include"
layout="#layout/toolbar" />
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="25dp"
card_view:cardElevation="10sp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#drawable/filebinder" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="14"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="vertical">
<TextView
android:id="#+id/dateDiary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="30 July"
android:textColor="#03a9f4"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#03a9f4" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/diarybookmark" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<EditText
android:id="#+id/diaryHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:ems="5"
android:fontFamily="sans-serif"
android:hint="Diary Heading"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="18sp" />
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/diaryTeacherName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:fontFamily="sans-serif"
android:hint="Teacher\'s Name..."
android:textSize="16sp" />
<at.markushi.ui.CircleButton
android:id="#+id/addDiaryEntry"
android:layout_width="74dip"
android:layout_height="74dip"
android:layout_gravity="right"
android:src="#drawable/ic_action_tick"
app:cb_color="#color/actionbar_title_color"
app:cb_pressedRingWidth="8dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:id="#+id/diaryContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/addDiaryEntry"
android:layout_alignLeft="#+id/scrollView"
android:layout_alignStart="#+id/scrollView"
android:layout_alignTop="#+id/scrollView"
android:fontFamily="sans-serif"
android:gravity="top"
android:hint="Enter Diary Note...\n\n\n\n"
android:text="Dear Parents,"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</LinearLayout>

Scrollview not working

This is my coding i have added a toolbar and i want the data below to scroll but its scrolling entirely.I Tried many solution in SO but still its of No use.Pls check and if found any error help me
Thanks in Advance
<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"
tools:context="com.agna.hrm_sainmarks.Address" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/White"
android:orientation="vertical" >
<include
android:id="#+id/emergencytoolbar"
layout="#layout/emergency_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/name"
android:textSize="18dp" />
<TextView
android:id="#+id/primname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Ajith Kumar"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View01"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/relationship"
android:textSize="18dp" />
<TextView
android:id="#+id/primrelationship"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Brother"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View02"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/phone"
android:textSize="18dp" />
<TextView
android:id="#+id/primphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="9998885231"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View03"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/taddress"
android:textSize="18dp" />
<TextView
android:id="#+id/primaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="78,Muthu nagar 3rd Street,Coimbatore-44"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View04"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
</ScrollView>
</LinearLayout>
</RelativeLayout>
emergency_toolbar
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- <android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#color/Hrmtool"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:titleTextColor="#color/Red" > -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:textColor="#color/Black"
android:weightSum="2"
>
<Button
android:id="#+id/pemergency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="#color/Hrmbg"
android:layout_weight="1"
android:textSize="18dp"
android:text="#string/pemergency"
android:textColor="#color/Black" />
<Button
android:id="#+id/semergency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="#color/Hrmbg"
android:layout_weight="1"
android:textSize="18dp"
android:text="#string/semergency"
android:textColor="#color/Black" />
</LinearLayout>
<!-- </android.support.v7.widget.Toolbar> -->
</RelativeLayout>
You need to do just few changes.
In emergency_toolbar.xml change the layout_height of RelativeLayout and LinearLayout to wrap_content.
In activity_main.xml put <include.... code outside LinearLayout and Inside of RelativeLayout.
You have to add LinearLayout just after ScrollView to wrap WHOLE fields as ScrollView can hold only one DIRECT CHILD.
Most important point: Add too many address field as you can see SCROLL at runtime. Just copy-paste address field and change the ids field of them.
Below is screen shot, which I have got as Outcome. And See this CodeLink.
Hope this will help.
ScrollView hold only one view as Childview try this code
<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"
tools:context="com.agna.hrm_sainmarks.Address">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/White"
android:orientation="vertical">
<include
android:id="#+id/emergencytoolbar"
layout="#layout/emergency_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/name"
android:textSize="18dp" />
<TextView
android:id="#+id/primname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Ajith Kumar"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View01"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/relationship"
android:textSize="18dp" />
<TextView
android:id="#+id/primrelationship"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Brother"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View02"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/phone"
android:textSize="18dp" />
<TextView
android:id="#+id/primphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="9998885231"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View03"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/taddress"
android:textSize="18dp" />
<TextView
android:id="#+id/primaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="78,Muthu nagar 3rd Street,Coimbatore-44"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View04"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
</LinearLayout>
</ScrollView>
</LinearLayout>
As Scroll View can hold only one direct child.You need to define it above Your Main Linear Layout. Also use Scroll Bars Property in Scroll View.
EDIT :
Move your Tool Bar Layout above Scroll View.
Try this code.
<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"
tools:context="com.agna.hrm_sainmarks.Address">
<include
android:id="#+id/emergencytoolbar"
layout="#layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/emergencytoolbar"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/app_name"
android:textSize="18dp" />
<TextView
android:id="#+id/primname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Ajith Kumar"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View01"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/app_name"
android:textSize="18dp" />
<TextView
android:id="#+id/primrelationship"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Brother"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View02"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="phone"
android:textSize="18dp" />
<TextView
android:id="#+id/primphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="9998885231"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View03"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textSize="18dp" />
<TextView
android:id="#+id/primaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="78,Muthu nagar 3rd Street,Coimbatore-44"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View04"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#FFFFFF" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Try this, I tried to add data to it and then scrolled. The views below toolbar are being scrolled as expected:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="in.net.codestar.ratingbar.MainActivity"
tools:showIn="#layout/activity_main">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/White"
android:orientation="vertical" >
<include
android:id="#+id/emergencytoolbar"
layout="#layout/emergency_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/name"
android:textSize="18dp" />
<TextView
android:id="#+id/primname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Ajith Kumar"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View01"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/relationship"
android:textSize="18dp" />
<TextView
android:id="#+id/primrelationship"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Brother"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View02"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/phone"
android:textSize="18dp" />
<TextView
android:id="#+id/primphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="9998885231"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View03"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/taddress"
android:textSize="18dp" />
<TextView
android:id="#+id/primaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="78,Muthu nagar 3rd Street,Coimbatore-4478,Muthu nagar 3rd Street,Coimbatore-44"
android:textSize="18dp" />
</LinearLayout>
<View
android:id="#+id/View04"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/Hrmbg" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
emergency_toobar.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:textColor="#color/Black"
android:weightSum="2"
>
<Button
android:id="#+id/pemergency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="#color/Hrmbg"
android:layout_weight="1"
android:textSize="18dp"
android:text="#string/pemergency"
android:textColor="#color/Black" />
<Button
android:id="#+id/semergency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="#color/Hrmbg"
android:layout_weight="1"
android:textSize="18dp"
android:text="#string/semergency"
android:textColor="#color/Black" />
</LinearLayout>
</RelativeLayout>
The following two lines solved my problem:
android:lines="4"
android:maxLines="4"
now it's working.

Categories

Resources