【问题标题】:How to change android showcaseview circle position?如何更改 android showviewview 圆圈位置?
【发布时间】:2016-07-21 06:02:59
【问题描述】:

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

我想把这个圆圈移动到 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();

【问题讨论】:

  • 你是如何设置.setTarget(new ActionViewTarget(this, ActionViewTarget.Type.HOME))?
  • mTVTitle = (TextView) findViewById(R.id.tv_title); .setTarget(new ViewTarget(mTVTitle))

标签: android showcaseview


【解决方案1】:

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

您必须修改您的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))

您已经完成了愉快的编码。

【讨论】:

  • 效果不一样,圆圈只聚焦中心
  • @BikeshMAnnur 然后添加您有问题的布局和代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-05
  • 2015-11-10
  • 2017-03-28
  • 2017-07-12
  • 1970-01-01
  • 2015-07-22
  • 1970-01-01
相关资源
最近更新 更多