如何在ShowcaseView中为ListView创建矩形视图

11
2个回答

3
请参考示例应用程序中的CustomShowcaseActivity。它创建了一个矩形展示框,并使用一个构造函数定义了CustomShowcaseView,从资源文件dimens.xml中设置展示框矩形的widthheight
width = resources.getDimension(R.dimen.custom_showcase_width);
height = resources.getDimension(R.dimen.custom_showcase_height);

CustomShowcaseActivityBuilder中的ShowcaseView相关联。这也是展示目标的设置位置。

CustomShowcaseView实现了ShowcaseDrawer,因此您可以使用setShowcaseDrawer()。它不是一个抽屉,而是一个“绘制器”。

以下显示了如何将其应用到您想要的listview

ViewTarget target = new ViewTarget(R.id.listView, this);

sv = new ShowcaseView.Builder(this)
            .setTarget(target)
            .setShowcaseDrawer(new CustomShowcaseActivity.CustomShowcaseView(getResources()))
            .build();

2
看一下这个:MaterialShowCaseView 这是原始ShowCaseView库的改进版本。 它有更多的特性,比如sequence.withRectangleShape()。 矩形展示的一个例子是:
    // single example
new MaterialShowcaseView.Builder(this)
    .setTarget(mButtonShow)
    .setDismissText("GOT IT")
    .withRectangleShape() // this makes it rectangle
    .setContentText("This is some amazing feature you should know about")
    .setDelay(withDelay) // optional but starting animations immediately in onCreate can make them choppy
    .singleUse(SHOWCASE_ID) // provide a unique ID used to ensure it is only shown once
    .show();

如果要将其用于其中一个项目,请在onBindViewHolder中使用if,并显示特定的position


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接