如何改变android showcaseview圈位?

时间:2016-07-21 06:02:59

标签: android showcaseview

我使用https://github.com/amlcurran/ShowcaseView库创建了展示视图。默认情况下,展示视图圆圈指向元素的中心。 enter image description here

我想将此圈移动到TextView的开头

请帮帮我

更新

我的布局

<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="com.bm.eg.activities.CreateProfileActivity">

     <LinearLayout

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <include layout="@layout/toolbar_transparent" />

                <TextView
                    android:id="@+id/tv_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:layout_marginLeft="40dp"
                    android:layout_marginRight="40dp"
                    android:layout_marginTop="8dp"
                    android:ellipsize="end"
                    android:hint="@string/hint_title"
                    android:singleLine="true"
                    android:textColor="@android:color/white"
                    android:textColorHint="@color/white_transparency_50"
                    android:textSize="24sp" />

活动

        mTVTitle = (TextView) findViewById(R.id.tv_title);

        mShowcaseView = new ShowcaseView.Builder(this)

                .setTarget(new ViewTarget(mTVTitle))
                .setContentTitle(getString(R.string.sv_create_profile_title))
                .setContentText(getString(R.string.sv_create_profile_title_description))
                .setStyle(R.style.CustomShowcaseTheme2)
                .blockAllTouches()
                .replaceEndButton(R.layout.showcase_view_cusom_button)

                .build();

1 个答案:

答案 0 :(得分:2)

最后,在研究了您的问题后,我找到了适合您的解决方案。

您必须修改layout design在设计中添加一个RelativeLayout,如下所示,并在其中添加两个 TextViews并添加tv_titlehack_txt textview一样,如下所示。

注意: hack_txt android:hint =“aaaaaa”必须在其中添加5或6个字符并设置android:visibility="invisible"

<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="com.bm.eg.activities.CreateProfileActivity">

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <include layout="@layout/toolbar_transparent" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_marginTop="8dp">

            <TextView
                android:id="@+id/tv_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:hint="@string/hint_title"
                android:singleLine="true"
                android:textColor="@android:color/white"
                android:textColorHint="@color/white_transparency_50"
                android:textSize="24sp" />

            <TextView
                android:id="@+id/hack_txt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:hint="aaaaaa"
                android:textSize="24sp"
                android:visibility="invisible" />
        </RelativeLayout>



        <!--... your other view-->
    </LinearLayout>
</RelativeLayout>

现在也在这里更新

 mTVTitle = (TextView) findViewById(R.id.tv_title);
 mTVHack = (TextView) findViewById(R.id.hack_txt);

最后也在这里更新。

.setTarget(new ViewTarget(mTVHack))

你做得很开心。

enter image description here