How to use a Listview inside a Scrollview

Asked

Viewed 387 times

0

Hi, I’m trying to use a Listview inside a Scrollview. The goal is to work similar to other apps that do this, such as instagram and the young nerd. Below my comment will be the code in xml and below it in java.Thank you

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#212121"
    android:orientation="vertical">


    <com.daimajia.slider.library.SliderLayout
        android:id="@+id/slImageResource"
        android:layout_width="match_parent"
        android:layout_height="205dp"
        android:layout_marginTop="0dp"
        android:scaleType="fitXY" />

    <com.daimajia.slider.library.Indicators.PagerIndicator
        android:id="@+id/custom_indicator"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="-4dp"
        android:gravity="center"
        custom:selected_color="#FFFFFF"
        custom:selected_height="6dp"
        custom:selected_padding_left="6dp"
        custom:selected_padding_right="6dp"
        custom:selected_width="6dp"
        custom:shape="oval"
        custom:unselected_color="#55333333"
        custom:unselected_height="6dp"
        custom:unselected_padding_left="2dp"
        custom:unselected_padding_right="2dp"
        custom:unselected_width="6dp" />

    <ListView
        android:id="@+id/list_test"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></ListView>


</LinearLayout>

slImages = (SliderLayout)rootView.findViewById(R.id.slImageResource);

        FSocietySlideView slideView = new FSocietySlideView(getContext());
        slideView.image(R.mipmap.ic_launcher);
        slideView.setOnSliderClickListener(HomeFragment.this);
        slideView.description("None");
        slImages.addSlider(slideView);

        final ArrayList<FSociety> news = new ArrayList<>();

        news.add(new FSociety(getResources(), "None", "None", R.mipmap.ic_launcher));
        news.add(new FSociety(getResources(), "None", "None", R.mipmap.ic_launcher));
        news.add(new FSociety(getResources(), "None", "None", R.mipmap.ic_launcher));
        news.add(new FSociety(getResources(), "None", "None", R.mipmap.ic_launcher));
        news.add(new FSociety(getResources(), "None", "None", R.mipmap.ic_launcher));
        news.add(new FSociety(getResources(), "None", "None", R.mipmap.ic_launcher));

        FSocietyAdapter adapter = new FSocietyAdapter(getActivity(),news);

        ListView listView = (ListView)rootView.findViewById(R.id.list_test);

        listView.setAdapter(adapter);

        return rootView;
    }

  • It is not clear which your doubt.. The listview itself already has scroll, because it needs to put it inside a scrollView?

  • Because I want the entire layout to move. With just listview, I’ll only be able to move the items in that list themselves. So I sited some of the apps that do this, so you can imagine what I want to do.

  • No one has a suggestion ;-;

1 answer

0

Place Listview inside a Linearlayout with fixed height. So you can put the Scroll in all Activity and even with the Scroll of Listview itself.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.