Hi I want to create a horizontal scrollview but it comes out as vertical. Can you help?
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<ListView
android:id="#+id/household_member_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</HorizontalScrollView>
Here is what appears:
Please help. Thanks.
You are using ListView inside of ScrollView, this will not work.
If you want to have horizontal ListView you need to use RecyclerView
More here:
Horizontal ListView in Android?
You can use recyclerview.
Set horizontal linear layout as layoutmanager for recyclerview to achieve horizontal scrolling
Related
I want to implement two RecyclerView with different layout in single activity. The above RecyclerView should scroll vertical and the one below should scroll horizontal. But when I run the app, only either one RecyclerView is displayed. If first view is displayed then it works properly and scrolls vertical, while second RecyclerView is missing. And if second one is displayed then it scrolls vertical when it should do horizontal scroll and the first RecyclerView is missing.
Here is what i want. Source: Github,CardView-Recyclerview-Picasso
Here is my layout
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorBackgroundLight"
android:smoothScrollbar="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/CategoriesRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/videoRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="130dp"
android:layout_below="#+id/CategoriesRecyclerView"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
You may directly use the 2 Recycler Views without NestedScrollView.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/CategoriesRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/videoRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="130dp"
android:layout_below="#+id/CategoriesRecyclerView"/>
</RelativeLayout>
And in your CategoriesRecyclerView whose height is wrap_content, use setAutoMeasureEnabled(true) on the Layout manager used for the recyler view.
If you want to scroll the horizontal scrollview full upside on page scroll then use scrollview otherwise you can do without scrollview. Also to achieve your layout just give the horizontal recyclerview fixed height and then you can see both recyclerview .
Im trying to rig a horizontally oriented RecyclerView with child items that contain a HorizontalScrollView. What I have configured right now is not allowing the nested HorizontalScrollView to scroll its content.
Heres an abbreviated version of my activity layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RecyclerView
android:id="#+id/home_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
And here's an abbreviated version of the item layout:
<android.support.v7.widget.CardView
android:id="#+id/main_card"
android:layout_width="335dp"
android:layout_height="match_parent">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"">
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</HorizontalScrollView>
</android.support.v7.widget.CardView
So Im trying to get the Text content inside the Horizontal ScrollView to be scrollable.
EDIT :
Below is a screenshot of the textview that will not scroll. As you can see, the text is cut off at the end of the view, and this is why Im looking to implement horizontal scrolling.
NOTE: I tried changing the LayoutManager associated with my RecyclerView to have vertical orientation, and horizontal scrolling works as expected. Knowing this, it seems that the RecyclerView is absorbing all scroll events and not allowing the nested HorizontalScrollView to do its thing
I think it can be achieved by NestedScrollingChild NestedScrollingParent.
But I can't really understand them.Who can help me out!
Product manager insists on the design.
The ScrollView contains a LinearLayout ,a "TabLayout" and a ViewPager.
The ViewPager contains 2 fragment contains RecyclerView or just only 2 RecyclerView.
When the ScrollView scroll to Bottom , the RecyclerView can scroll to Bottom.
When the RecyclerView scroll to Top , the ScrollView can scroll to Top.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="1000dp" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="60dp"></TableLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v4.view.ViewPager>
</LinearLayout>
</ScrollView>
Just change your ScrollView to android.support.v4.widget.NestedScrollView
Post your xml if that doesn't work
ِYou can do that, but it's not good at all to use this type of layout
First you need add "wrap_content" abilty ViewPager and RecyclerView's
ViewPager and RecyclerView
Now you can use scrollview easily, put all item in it
If you want some effect or something when user scrolling or some item get visible in scrolling you can get position of item then make listener on
"OnScrollChangedListener" of scrollview
I have the listView in the NestedScrollView since the nested scrollView are out of the screen so some list will not be shown
You need to use RecyclerView inside NestedScrollView. And wrap it with custom LinearLayoutManager.
How to use RecyclerView inside NestedScrollView?
For the fast fix just put it in linear layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.nhaarman.listviewanimations.itemmanipulation.DynamicListView
android:id="#+id/listViewTaskInComplete"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
In my Android app I wanna use a ScrollView and it must be scrollable to both X-axis and Y-axis. Without using both ScrollView and HorizontalScrollView as I did cant I use one ScrollView and enable both scrolls. What I did is below.
<ScrollView
android:id="#+id/srv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ll1" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/linearMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical" >
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
Is it possible to use just one scroll view and enable both scrolls. Thank You!!
AFAIK, No.
ScrollView is for vertical scrolling, as is ListView.
HorizontalScrollView is only for horizontal scrolling.
To implement both x and y axis scrolling, you must use both ScrollView and HorizontalScrollView as you have done.