Java 克劳顿居中自定义视图和消失问题
今天我把吐司换成了克劳顿。 但我有这些问题: 1)显示克劳顿在中间位置 2)每当我想展示新的克劳顿时,它都会再次展示上一个克劳顿,尽管上一个很久以前就隐藏了 我想知道是否有更好的方法来解决上述问题??因为我查看了样本和库,但没有找到“ 目前我正在解决这些问题 活动布局: 为了解决第二个问题,我必须下载库源代码并使用它。因为我不想首先使用动画,所以我禁用了动画Java 克劳顿居中自定义视图和消失问题,java,android,crouton,Java,Android,Crouton,今天我把吐司换成了克劳顿。 但我有这些问题: 1)显示克劳顿在中间位置 2)每当我想展示新的克劳顿时,它都会再次展示上一个克劳顿,尽管上一个很久以前就隐藏了 我想知道是否有更好的方法来解决上述问题??因为我查看了样本和库,但没有找到“ 目前我正在解决这些问题 活动布局: 为了解决第二个问题,我必须下载库源代码并使用它。因为我不想首先使用动画,所以我禁用了动画 //croutonView.startAnimation(crouton.getInAnimation()); 关于删除使内容再次
//croutonView.startAnimation(crouton.getInAnimation());
关于删除使内容再次出现在内部的函数的问题
protectedvoid removeCrouton(克劳顿·克劳顿)
我相信我遗漏了一些东西。希望已经有正确的方法来做这些事情。不鼓励在库中进行更改,因为这可能会产生一些问题,而这些问题只会出现在您的Crouton版本中 您可以通过
Configuration.Builder.setInAnimation(…)
和.setOutAnimation(…)
更改动画
配置
可以重复使用,并且不必每次显示面包圈
时都创建该配置。这同样适用于您的视图
。它不必每次都充气
关于Crouton的重复显示:此行为不是故意的。
上面的代码看起来应该显示带有
info
文本集的面包片。如果您的info
文本在面包片显示过程中发生了更改,则可能是库中存在错误。如果是这种情况,请放心。是的。我直接下载了库,并使用setInAnimation将其清理干净。它似乎可以正常工作。以前的hi在第二个开始显示之前,ded Crouton没有再次显示。我想知道你提到我可以使用膨胀的相同视图。如果我在添加不同文本之前不取消Crouton,它会正常工作吗?另外,正如我上面所问的,有没有优雅的方法将Crouton居中。因为我在里面没有找到任何方法电子图书馆
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/kdrw"
android:orientation="horizontal"
android:padding="8dp" >
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="8dp"
android:contentDescription="@string/strnull"
android:src="@drawable/logo" />
<TextView
android:id="@+id/toasttextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
LayoutInflater inflater = localdsr.getLayoutInflater();
View layout = inflater.inflate(R.layout.toast, null);
TextView text = (TextView) layout.findViewById(R.id.toasttextView1);
text.setText(info);
if (toast != null)
toast.cancel();
Configuration croutonConfiguration=new Configuration.Builder().setDuration(1500).build();
toast=Crouton.make(localdsr, layout ,R.id.alternate_view_group ,croutonConfiguration);
toast.show();
//croutonView.startAnimation(crouton.getInAnimation());
//sendMessageDelayed(crouton, Messages.DISPLAY_CROUTON, crouton.getOutAnimation().getDuration());
//I changed it with below .plus removed crouton.getOutAnimation().getDuration() so it does not throw exception
sendMessage(crouton, Messages.DISPLAY_CROUTON);