Android Showcase View how to use?

2020-02-01 02:58发布

问题:

Well For Showcase View

I using this:

https://github.com/amlcurran/ShowcaseView

After importing files it gives error. this is my errors and improted .jar files

Errors says

in java

R cannot be resolved to a variable

in style

error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light'.

again, in style

error: Error: No resource found that matches the given name: attr 'android:fontFamily'.

Also Are there any tutorial to use Showcase view in my project. I can not find and I didnt understant from github project. it is not clear.

回答1:

This library works Awesome for all. How it works?? i want to highlight a toolbar option. Now just add the library and write code like this.

you can use multiple showCaseView using this code

1 add Library in our Gradle.build implementation 'com.github.mreram:ShowCaseView:1.0.5'

simple call this method with pass title, Description Text, view or view Id and Type

  ShowIntro("SetTheme", "Select Theme and Apply on your video", R.id.button_tool_theme, 1);

method create like this

 private void ShowIntro(String title, String text, int viewId, final int type) {

    new GuideView.Builder(this)
            .setTitle(title)
            .setContentText(text)
            .setTargetView((LinearLayout)findViewById(viewId))
            .setContentTextSize(12)//optional
            .setTitleTextSize(14)//optional
            .setDismissType(GuideView.DismissType.targetView) //optional - default dismissible by TargetView
            .setGuideListener(new GuideView.GuideListener() {
                    @Override
                    public void onDismiss(View view) {
                        if (type == 1) {
                            ShowIntro("Editor", "Edit any photo from selected photos than Apply on your video", R.id.button_tool_editor, 6);
                        } else if (type == 6) {
                            ShowIntro("Duration", "Set duration between photos", R.id.button_tool_duration, 2);
                        } else if (type == 2) {
                            ShowIntro("Filter", "Add filter to video ", R.id.button_tool_effect, 4);
                        } else if (type == 4) {
                            ShowIntro("Add Song", "Add your selected song on your video ", R.id.button_tool_music, 3);
                        } else if (type == 3) {
                            ShowIntro("Overlay", "Add your selected overlay effect on your video ", R.id.button_tool_overlay, 5);
                        } else if (type == 5) {
                            SharePrefUtils.putBoolean("showcase", false);
                        }
                    }
                })
            .build()
            .show();
}


回答2:

Here for this I am using this library

https://github.com/amlcurran/ShowcaseView

This library works really great. How it works?? Suppose i want to highlight a menu option. Now just add the library and white this code.

    Toolbar toolbar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.menu_main);
    setSupportActionBar(toolbar);

    ViewTarget target = new ViewTarget(toolbar.findViewById(R.id.menu_id_launcher));

    new ShowcaseView.Builder(this)
            .setContentTitle("Its My Navigation Drawer")
            .setContentText("Click here and you will get options to navigate to other sections.")
            .useDecorViewAsParent() //this is the difference
            .setTarget(target)
            .build();
}

and finally you have to make your menu show always like this

    <item
      android:id="@+id/menu_id_launcher"
      android:orderInCategory="100"
      android:icon="@mipmap/ic_launcher"
      android:title="@string/action_settings"
      app:showAsAction="always" />

Now just run the app i think this will works perfectly.



回答3:

I usually use another library for showcase views. It creates bubbles instead of concentric circles but it works really well. Maybe it is also useful for your requirements and with this one you don't have importing problems.

You just have to add 'implementation 'com.elconfidencial.bubbleshowcase:bubbleshowcase:1.3.0' in your build.gradle file of your app and synchronize your project.

It works similar to ShowCaseView library:

BubbleShowCaseBuilder(this) //Activity instance
            .title("foo") //Any title for the bubble view
            .targetView(view) //View to point out
            .show() //Display the ShowCase

Source https://github.com/ECLaboratorio/BubbleShowCase-Android



回答4:

The sample you use needs the ActionBarSherlock Library, you can read it in the instructions from the github page: "To use the sample download ActionBarSherlock and add it as a dependency to the library project. Use point 1 on the "Including in your project" instructions at the link."

  • download ActionBarSherlock and import it (only the library, you don't need the samples)
  • right click to your SampleActivity project and choose Properties
  • choose Android, click Add and include the ActionBarSherlock project

Then the style errors will go away and R can be built.



回答5:

  • import, add actionbarsherlock library
  • android:fontFamily minSDK is 16, or delete this
  • project -> clean all