-1

I have 10 strings and I need to show all these strings in a textview one by one sliding to left automatically, and I have 2 buttons one button is to stop that and one button is start autoscrolling again. i.e when I click on start button, textview will be displayed with first string and then next string something like autoscrolling view pager.When click on stop button Textview should freeze with current string.Can anyone help me on this? how can I achieve this?

Thanks in-advance.

Sri
  • 165
  • 2
  • 3
  • 12
  • 1
    share some code... please – Damodhar Dec 03 '19 at 09:58
  • I am not sure how can I achieve that? I have 10 user names, I have a text view, I need to show that 10 names in this textview. i.e, I need to show 1st name then it will slide to right to left and then second should be visible and slide right to left and then third one should be visible. When I click on stop button , the current displaying name should be visible and freeze. I want a functionality like this. I am confused how to start it. – Sri Dec 04 '19 at 09:37

1 Answers1

0

You should try to give attempt to write your code and then ask for suggestion based on your logic. However i would suggest you to make use of the following link

Example:

implementation 'com.github.smarteist:autoimageslider:1.2.0'

implementation 'com.github.bumptech.glide:glide:4.7.1'

Just put the view in the layout xml like this:

 <com.smarteist.autoimageslider.SliderLayout
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_alignParentTop="true"
    android:id="@+id/imageSlider"/>

And implement the slider with your own programming Here is an example of the implementation of this library in java :

        SliderLayout sliderLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sliderLayout = findViewById(R.id.imageSlider);
    sliderLayout.setIndicatorAnimation(SliderLayout.Animations.FILL); //set indicator animation by using SliderLayout.Animations. :WORM or THIN_WORM or COLOR or DROP or FILL or NONE or SCALE or SCALE_DOWN or SLIDE and SWAP!!
    sliderLayout.setScrollTimeInSec(1); //set scroll delay in seconds :

    setSliderViews();
}

private void setSliderViews() {

    for (int i = 0; i <= 3; i++) {

        SliderView sliderView = new SliderView(this);
//You can ignore the next switch case as you dont have image requirement

 /*       switch (i) {
            case 0:
                sliderView.setImageUrl("https://images.pexels.com/photos/547114/pexels-photo-547114.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
                break;
            case 1:
                sliderView.setImageUrl("https://images.pexels.com/photos/218983/pexels-photo-218983.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
                break;
            case 2:
                sliderView.setImageUrl("https://images.pexels.com/photos/747964/pexels-photo-747964.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260");
                break;
            case 3:
                sliderView.setImageUrl("https://images.pexels.com/photos/929778/pexels-photo-929778.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
                break;
        }

        sliderView.setImageScaleType(ImageView.ScaleType.CENTER_CROP);*/ 
        sliderView.setDescription("setDescription " + (i + 1));
        final int finalI = i;
        sliderView.setOnSliderClickListener(new SliderView.OnSliderClickListener() {
            @Override
            public void onSliderClick(SliderView sliderView) {
                Toast.makeText(MainActivity.this, "This is slider " + (finalI + 1), Toast.LENGTH_SHORT).show();
            }
        });

        //at last add this view in your layout :
        sliderLayout.addSliderView(sliderView);
    }
}
Community
  • 1
  • 1
Vinay Jayaram
  • 1,030
  • 9
  • 29