Search code examples
androidandroid-viewpagerhorizontalscrollview

How to design a slider view like the one as described in image and pass image from URL


I am designing a user interface or say a view.

What approach should I use to design a sliding user interface the one as shown in the image?

Sliders

EDITED: 25 AUGUST 2017

I am not aware of different views that can be used in creating the UI as shown in the image. So it will be helpful if some one tell me which view or view group should I used to obtain the same results and Also how can I render image from a URL


Solution

  • By using viewpager i have done this. It works well.

    here are some code snippets

    Initialization

        LayoutInflater flater = (LayoutInflater) LayoutInflater.from(this);
        view1 = flater.inflate(R.layout.view_1, null);
        view2 = flater.inflate(R.layout.view_2, null);
        view3 = flater.inflate(R.layout.view_3, null);
    
        viewList = new ArrayList<View>();
        viewList.add(view1);
        viewList.add(view2);
        viewList.add(view3);
    
        pagerAdapter = new MyViewPagerAdapter(viewList);
    
        viewPager = (ViewPager) findViewById(R.id.search_viewpager);
        viewPager.setAdapter(pagerAdapter);
        viewPager.setCurrentItem(0);
    
        viewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    

    INSIDE XML

        <android.support.v4.view.ViewPager  
            android:id="@+id/search_viewpager"  
            android:layout_width="wrap_content"  
            android:layout_height="200dp"  
            android:layout_gravity="center"  
            android:layout_weight="1.0"  
            android:background="#000000"  
            android:flipInterval="30"  
            android:persistentDrawingCache="animation" >