Professional Documents
Culture Documents
Sampl
Sampl
android:layout_width="match_parent"
android:layout_height="250dp"
app:sliderScrollTimeInSec="1"
app:sliderAnimationDuration="1000"
app:sliderAutoCycleDirection="back_and_forth"
app:sliderIndicatorRadius="2dp"
app:sliderIndicatorSelectedColor="#5C5858"
app:sliderIndicatorUnselectedColor="#c1c1c1"
app:sliderStartAutoCycle="true"/>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/image"
android:scaleType="fitXY"
android:adjustViewBounds="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@drawable/bg_overlay"
android:layout_alignParentBottom="true">
<TextView
android:id="@+id/textDesc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="vinayak"
android:textColor="#fff"
android:textSize="22sp"
android:textStyle="bold"
android:gravity="center"/>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="@color/black"
android:endColor="@android:color/transparent"
android:angle="90"/>
</shape>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sliderView = findViewById(R.id.sliderview);
images = new int[]{R.drawable.indiaflag,R.drawable.cp};
text = new String[]{"IndiaFlag","C Programming"};
sliderView.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
sliderView.setIndicatorAnimation(IndicatorAnimationType.DROP);
sliderView.startAutoCycle();
@Override
public Holder onCreateViewHolder(ViewGroup parent) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.slider_item,parent,false)
;
return new Holder(view);
}
@Override
public void onBindViewHolder(Holder viewHolder, int position) {
viewHolder.imageView.setImageResource(images[position]);
viewHolder.textView.setText(text[position]);
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Toast.makeText(, "", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public int getCount() {
return images.length;
}
public class Holder extends SliderViewAdapter.ViewHolder{
imageView = itemView.findViewById(R.id.image);
textView = itemView.findViewById(R.id.textDesc);
}
}