ShowTips选择了错误的位置



我想在我的Android项目中展示技巧。这是我的片段的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:id="@+id/lineLayout"
    android:clickable="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#231f20">
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:elevation="4dp"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="#FAC80A"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/textView77"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Home"
                    android:textColor="#231f20"
                    android:textSize="20sp"
                    android:layout_centerVertical="true" />
                <ImageView
                    android:id="@+id/imageView129"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="60dp"
                    android:src="@drawable/cta_ic_search_grey"
                    android:paddingLeft="7dp"
                    android:layout_centerVertical="true"
                    android:paddingTop="7dp"
                    android:paddingBottom="7dp" />
                <ImageView
                    android:id="@+id/imageView130"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="20dp"
                    android:src="@drawable/cta_ic_notifications_grey"
                    android:layout_centerVertical="true" />
            </RelativeLayout>
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>
    <ListView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/appbar"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/fab"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom|end"
        android:paddingRight="16dp"
        android:paddingBottom="16dp"
        android:paddingLeft="10dp"
        fab:menu_buttonSpacing="10dp"
        fab:menu_labels_style="@style/MenuLabelsStyle"
        fab:menu_labels_showAnimation="@anim/jump_from_down"
        fab:menu_labels_hideAnimation="@anim/jump_to_down"
        fab:menu_animationDelayPerItem="0"
        fab:menu_shadowColor="#444"
        fab:menu_icon="@drawable/cta_ic_add"
        fab:menu_colorNormal="#FAC80A"
        fab:menu_colorPressed="#e2b509"
        fab:menu_colorRipple="#99FFFFFF"
        fab:menu_labels_margin="8dp"
        fab:menu_backgroundColor="#CC231f20">
        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabAlbum"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/cta_ic_add_photo_from_album_icon_default_state"
            fab:fab_size="mini"
            fab:fab_colorNormal="#FAC80A"
            fab:fab_colorPressed="#e2b509"
            fab:fab_colorRipple="#99FFFFFF"
            fab:fab_label="Add Photo from Album" />
        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabFacebook"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/cta_ic_add_photo_from_fb_icon_default_state"
            fab:fab_size="mini"
            fab:fab_colorNormal="#FAC80A"
            fab:fab_colorPressed="#e2b509"
            fab:fab_colorRipple="#99FFFFFF"
            fab:fab_label="Add Photo from Facebook" />
    </com.github.clans.fab.FloatingActionMenu>
</RelativeLayout>

以下是显示提示的代码:

public void showTip() {
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                ShowTipsView tip4 = new ShowTipsBuilder(getActivity())
                        .setTarget(fab)
                        .setTitle("Add Photos")
                        .displayOneTime(4)
                        .setDescription("Add Photos from your FB, Instagram albums or from your smart phone.")
                        .setDelay(1000)
                        .build();
                tip4.show(getActivity());
            }
        }, 1000);
    }

正如你所看到的,我正在使用Clans Fab来展示一个Fab。我已经尝试过ShowTipsView和ShowCaseView在我的代码中显示关于FloatingActionMenuid作为fab的提示。问题是这些库都没有选择正确的资产。两者都只是在手机屏幕的中心盘旋并显示提示。为什么会发生这种情况?如何解决这个问题?

ShowcaseView非常有缺陷,有时会将其文本项放在屏幕之外。

还有一个类似的库,叫做SuperToolTips。你可以试一试。

最新更新