How to set image slider on header in android

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

How to set image slider on header in android



I am new in android developing please help me.
I want to set image slider at the top on page and image are dynamic come through web service. example of image slider like below:-enter image description here



just like a slider show in this image (Back Story shop fro Backpacks) same i also want and remember image are dynamic.



My activity.main.xml:


<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
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/linear_layout_outer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="@+id/linear_layout_outer">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
custom:pager_animation="Accordion"
custom:auto_cycle="true"
custom:indicator_visibility="visible"
custom:pager_animation_span="1100" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<HorizontalScrollView
android:id="@+id/linear_layout_special_product_horizontal_scroll_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:id="@+id/linear_layout_special_produce_image01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shop240x320"
android:paddingRight="65dp"
android:contentDescription="@string/special_producr"/>

<ImageView
android:id="@+id/linear_layout_special_produce_image02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shop240x320"
android:paddingRight="65dp"
android:contentDescription="@string/special_producr"/>

<ImageView
android:id="@+id/linear_layout_special_produce_image03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shop240x320"
android:paddingRight="65dp"
android:contentDescription="@string/special_producr"/>

<ImageView
android:id="@+id/linear_layout_special_produce_image04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shop240x320"
android:paddingRight="65dp"
android:contentDescription="@string/special_producr"/>

<ImageView
android:id="@+id/linear_layout_special_produce_image05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shop240x320"
android:paddingRight="65dp"
android:contentDescription="@string/special_producr"/>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout>
</ScrollView></RelativeLayout>



currently it showing like this:-



enter image description here



and this give also a error Failed to find style 'SliderStyle' in current theme what is the meaning





use ViewPager with layout beneath...
– Mohit
Oct 6 '15 at 7:00


ViewPager





I try but i can't set image dynamic in view pager
– Anand Jain
Oct 6 '15 at 7:01





ViewPager with PagerAdapter or FragmentPagerAdapter is something that you should look into.
– Terril Thomas
Oct 6 '15 at 7:02





post your error//
– Mohit
Oct 6 '15 at 7:03





This can be achieve by viewpager with page indicator(for the dots below). You need to post your code for better explanation.
– Kunu
Oct 6 '15 at 7:33





3 Answers
3



Instead of tring to making it yourself, use nice and simple libraries. Here is one of them.





Thnaks @Amir Its works fine
– Anand Jain
Nov 3 '15 at 5:09



There are plenty of ways to achieve what you want like :
1. Via Using View Pager.
2. Using Recycler View (and set Layout Manager Orientation HORIZONTAL).



These Above two are the simplest and basic widgets use to render Image view(or other views) in above mentioned design format.



Now there is one more thing what you need is : to render Your Actual image in these Image Views.
I assume you are getting a list of Url's from some web service. Now you need to render those url's into your ImageView. For this you can use 3rd party library like picaso or Aquery.



the key part is In your adapter which you are attaching to these widgets, first pass the list of Urls to that Adapter and then set Image View Source with the help of one of these libraries.



You can use this library
https://github.com/MoeidHeidari/banner/tree/master
G'd luck





A link-only answer is not recommended and is liable to downvotes at best and deletion at worst. Can you please briefly describe how your library works?
– Mulliganaceous
20 mins ago






Please don't just post some tool or library as an answer. At least demonstrate how it solves the problem in the answer itself.
– Yunnosch
16 mins ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Hystrix command on request collapser fallback