How to fix this showcase button

920 views Asked by At

i am getting problem with the showcase View button which is showing below the soft key in android marshmallow but it perfectly showing in kitkat version.

here is the view how it looks in marshmallow version

enter image description here

and how it looks in kitkat version

enter image description here

here is my code

MainActivity

private int counter = 0;
private ShowcaseView showcaseView;
Target t1,t2,t3;
Button b1,b2,b3;

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


    t1 = new ViewTarget(R.id.button, this);
    t2 = new ViewTarget(R.id.button2, this);
    t3 = new ViewTarget(R.id.button3, this);

    showcaseView = new ShowcaseView.Builder(this)
            .setTarget(Target.NONE).setOnClickListener(this)
            .setContentTitle("Title")
            .setContentText("Here you can see the Showcase text")
            .build();
    showcaseView.setButtonText("Next");
}

@Override
public void onClick(View v) {
    switch (counter) {
        case 0:
            showcaseView.setShowcase(t1, true);
            showcaseView.setContentTitle("Button 1");
            showcaseView.setContentText("See function about the button one");
            break;
        case 1:
            showcaseView.setShowcase(t2, true);
            showcaseView.setContentTitle("Button 2");
            showcaseView.setContentText("See function about the button Two");
            break;
        case 2:
            showcaseView.setShowcase(t3, true);
            showcaseView.setContentTitle("Button 3");
            showcaseView.setContentText("See function about the button THREE");
            showcaseView.setButtonText("GOT IT");
            break;
        case 3:
            showcaseView.hide();
            break;
    }
    counter++;
}

}

how can i fix this

1

There are 1 answers

0
Vikash Singh On

i got the answer,

set the position of the layout of the button to the build version above 21

if (Build.VERSION.SDK_INT >= 21) {
                showcaseView.setButtonPosition(lps);
            }