Android “始终定位”;明白了;屏幕左下角的MaterialShowcaseView按钮
我正在使用以下库: 我一直在寻找一种方法(连续两天!)总是将“得到它”按钮放在屏幕左下角。我如何简单有效地做到这一点 我将立即接受工作答复。正如你所看到的,我一直都接受答案 根据Osama的回答,我得到了一个错误:Android “始终定位”;明白了;屏幕左下角的MaterialShowcaseView按钮,android,Android,我正在使用以下库: 我一直在寻找一种方法(连续两天!)总是将“得到它”按钮放在屏幕左下角。我如何简单有效地做到这一点 我将立即接受工作答复。正如你所看到的,我一直都接受答案 根据Osama的回答,我得到了一个错误: com.example.me.myapplication E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.me.myapplication, PID: 4445 java.lang.Illeg
com.example.me.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.me.myapplication, PID: 4445
java.lang.IllegalStateException: Cannot start this animator on a detached view!
at android.view.RenderNode.addAnimator(RenderNode.java:812)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282)
at android.animation.RevealAnimator.<init>(RevealAnimator.java:37)
at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:55)
at uk.co.deanwild.materialshowcaseview.CircularRevealAnimationFactory.animateInView(CircularRevealAnimationFactory.java:29)
at uk.co.deanwild.materialshowcaseview.MaterialShowcaseView.animateIn(MaterialShowcaseView.java:825)
at uk.co.deanwild.materialshowcaseview.MaterialShowcaseView$1.run(MaterialShowcaseView.java:794)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.me.myapplication.MainActivity">
<TextView
android:id="@+id/hi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.419" />
</android.support.constraint.ConstraintLayout>
此库基于,请查看它
您还可以转到库模块的showcase\u content.xml
,将tv\u disease
即“GOT IT”TextView
放入RelativeLayout
中,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_box"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
android:weightSum="1">
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:textSize="30dp" />
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:textSize="20dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="@+id/tv_dismiss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:layout_alignParentBottom="true"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="10dp"
android:textColor="@android:color/white"
android:textSize="22dp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
转到MaterialShowcaseView.java
并清空applyLayoutParams()
方法,并将setDelay
更新为1000
在生成器中,添加以下代码
mDismissButton.setGravity(Gravity.BOTTOM);
在构建器中。您能给出一个示例吗?谢谢,但是我如何编辑
showcase\u content.xml
?我的build.grade中有这样一个文件:compile'com.github.deano2390:MaterialShowcaseView:1.1.0'
从github下载这个简单的文件,转到文件>导入模块>从下载的文件中选择库,转到你的gradle文件添加这个编译项目(“:library”)
对于您的家属,android studiofile>new>import module中没有文件>导入模块之类的东西,请让我试试,几分钟后我会通知您
mDismissButton.setGravity(Gravity.BOTTOM);