How can I use listview inside a scrollview in android? - java

This is the image I want in my application:
I tried using listview inside a scrollview but the problem is that I am not able to stretch listview to its full size. Can anyone tell me how can I do this??

You can use your recyclerview as below example :
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<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:orientation="vertical"
app:layout_collapseMode="pin">
<!-- Some views-->
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_bubhub_comment_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
You can use below properties in recyclerview if you need both layout to scroll. Otherwise it would work as single scrolling view. These properties allows Recyclerview to scroll inside NestedScrollView
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
app:layout_behavior="#string/appbar_scrolling_view_behavior"

Related

Combine scrolling of Horizontal recyclerview which is inside Vertical RecyclerAdapter

Here parent having vertical recyclerview scroll and child having horizontal recyclerview ,I just wants to scroll all child together not individually currently child scrolling individually that’s a problem I am facing .I hope I explained well .If anyone have some suggestion or solution please provide I shall be really thankful to you.Check attached image
`
Parent view
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/appointments_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/_10ssp"
android:paddingRight="#dimen/_10ssp">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
Adapter View containing horizontal recyclerview.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.app.barber.views.CustomTextView
android:id="#+id/time_slot"
android:layout_width="#dimen/_40ssp"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingTop="#dimen/_2sdp"
android:paddingRight="#dimen/_2sdp"
android:paddingBottom="#dimen/_2sdp"
android:text="9:00 AM"
android:textSize="#dimen/_10ssp"
android:textStyle="bold" />
<View
android:layout_width="0.001sp"
android:layout_height="match_parent"
android:background="#color/color_light_grey_blue" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/days_recyclar"
android:layout_width="#dimen/_500sdp"
android:layout_height="wrap_content"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>

Increase font size of RecyclerView items

I have a navigation bar with RecyclerView that has different items. I wish to change the font size of it.
Here is the code for navigation_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/app_background"
android:textSize="30sp"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/nav_header_main" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp" />
</LinearLayout>
</ScrollView>
First and easiest way i think about is change the font size directly in your single item.
But if for some reason you dont want to do so, try to read this: Android change TextView textSize on RecyclerView adapter from Activity

Making LinearLayout with ListView scrollable

I have a linear layout that looks something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linear_layout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical"
tools:context=".activities.EnrolStudentFormActivity">
<include
layout="#layout/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true" />
<ListView
android:id="#+id/list_view
android:layout_width="match_pare
android:layout_height="wrap_cont
android:divider="#null"
android:dividerHeight="0dp" />
</LinearLayout>
With a few ImageViews, TextInputLayouts and TextInputEditTexts in between. I want to make this layout scrollable. I tried to make it scrollable with ScrollView and NestedScrollView, but both of them messed the ListView up.
I am also changing the ListView contents dynamically and I have a few TextInputEditTexts inside TextInputLayouts inside the ListView. Resizing the ListView doesn't help much, and I cannot click on the TextInputEditText inside the ListView. It seems that the ScrollView captures the touch input.
Are there any workarounds that will let me have a ListView inside a ScrollView or make the linear layout scrollable while making the TextInputEditText inside the ListView usable?
Use RecyclerView instead of ListView and add NestedScrollView on top:
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="
http://schemas.android.com/apk/res/android"
xmlns:http="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical"
tools:context=".activities.EnrolStudentFormActivity">
<include
layout="#layout/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true" />
<android.support.v7.widget.RecyclerView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#null"
android:dividerHeight="0dp" />>
</LinearLayout>
and finally in your code add:
RecyclerView.setNestedScrollingEnabled(false);

Scroll up Relative Layout when scrolling up listview

I'm creating an application. and the user information is shown in a relative layout. Under the relative layout is a listview with items the user created. I want if you scroll down in the List View that the Relative Layout scroll up and eventually disappeared, and the list view is stretched over the whole screen.
Like you have in de facebook app.
Facebook Scrolling image
How do I do this, this is my layout file:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6">
<ImageView
android:id="#+id/BackgroundPictureOther"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#eeeeee" />
<ImageView
android:id="#+id/profileOther"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#444444"
android:scaleType="fitXY"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"/>
<TextView
android:id="#+id/profileName"
android:layout_width="wrap_content"
android:minWidth="150dp"
android:layout_centerHorizontal="true"
android:textColor="#aaa"
android:textAlignment="center"
android:textSize="30sp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"></ListView>
</LinearLayout>
</merge>
Thanks in advance!
You have 2 options here:
1) You should put your entire layout inside NestedScrollView and change ListView into RecyclerView.
2) Or you can set your layout with profile picture as header view for listview.
For this you need to put your layout with profile in other xml layout file, then inflate it in code and use listview.addHeaderView(view v)

How to overcome this problem with using more listviews in a layout

I'm using 4 listviews in my layout and if i use scrollview , i cannot scroll into my listview. If i remove scrollview in my xml, then the last list is been hiddden. How to overcome this problem?
My code goes below:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="#id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="42.0dip">
<Button android:textSize="23.0dip" android:onClick="newtodo_Click" android:textStyle="bold" android:textColor="#ffffffff" android:gravity="center" android:id="#id/btnNewTodo" android:background="#drawable/new_todo" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
<TextView android:textColor="#000000" android:layout_height="wrap_content" android:background="#FF0000" android:layout_width="match_parent" android:text="High Priority" android:id="#+id/textView1"></TextView>
<ListView android:id="#+id/lvhigh" android:cacheColorHint="#00000000" android:background="#000000" android:layout_width="match_parent" android:layout_height="175px"></ListView>
<TextView android:background="#ffff01" android:textColor="#000000" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Medium Priority" android:id="#+id/textView2"></TextView>
<ListView android:id="#+id/lvmed" android:layout_width="match_parent" android:layout_height="175px"></ListView>
<TextView android:background="#00ff01" android:textColor="#000000" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Low Priority" android:id="#+id/textView3"></TextView>
<ListView android:id="#+id/lvlow" android:layout_width="match_parent" android:layout_height="175px"></ListView>
<TextView android:background="#cccccc" android:textColor="#000000" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Incomplete Tasks" android:id="#+id/textView4"></TextView>
<ListView android:id="#+id/lvinc" android:layout_width="match_parent" android:layout_height="175px"></ListView>
</LinearLayout>
</ScrollView>
Any Help is really appreciated and thanks in advance...
In you layout there is textview and after that listview so why you not used expandable listVIew.It will help you in your problem.
Here is example of Expandable listview
Expandable Listview
Expandable Listview example
Click Here
Click Here
An simple workaround is to
Remove ScrollView
Set height of all ListView to 0
Set layout_weight property of all child to 1
To overcome, try re-factoring your UI to not include multiple scrollable objects inside of another scrollable object. This will not be reliable and will produce unexpected results (as you have found).
As the100rabh said, this is generally bad design. Normally an application will present a list of some sort to a user. Four lists for a screen that is 2-5 (~10 for tablets) inches is three too many.
please set your listview as a non scrolling container By using
ls_edu.setScrollContainer(false);
it may help to scroll the list view.

Categories

Resources