首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ShowcaseView未居中

ShowcaseView未居中
EN

Stack Overflow用户
提问于 2016-06-20 19:50:25
回答 1查看 182关注 0票数 0

我有一个奇怪的错误,当退出应用程序并重新进入它时,ShowcaseView没有居中,我在片段中使用了这段代码。这是我的代码:

代码语言:javascript
复制
target = new ViewTarget(iv_QR);
            if (showcase == null) {
                Button button = new Button(getContext());
                button.setText("Got it !");
                button.setEnabled(false);
                button.setVisibility(View.INVISIBLE);
                showcase = new ShowcaseView.Builder(getActivity())
                        .setStyle(R.style.CustomShowcaseTheme2)
                        .replaceEndButton(button)
                        .setTarget(target)
                        .withMaterialShowcase()
                        .setContentTitle("QR Scan(Required)")
                        .setContentText("Please press the QR icon to scan the QR")
                        .build();

这是我的xml:

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Fragments.QRFragment">


    <ImageView
        android:id="@+id/iv_QR"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@mipmap/qricon" />
</RelativeLayout>

我附加了一个图像:

EN

回答 1

Stack Overflow用户

发布于 2016-06-20 21:05:46

因此,假设问题是由在onCreateView()返回之前创建的ShowcaseView引起的,请考虑在片段的onActivityCreated()方法中创建并显示ShowcaseView

ShowcaseViewHere is some sample code正在与片段一起使用,请尝试在您自己的代码中实现它。如您所见,它还使用了onActivityCreated()方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37921810

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档