【发布时间】:2015-05-05 09:11:41
【问题描述】:
我试图从文本更改侦听器中隐藏工具栏
public void onTextChanged(CharSequence s, int start, int before, int count) {
toolbar.animate()
.translationY(-toolbar.getBottom())
.setInterpolator(new AccelerateInterpolator())
.start();
}
此解决方案在更高级别的 api 上完美运行(成功在 kitkat 上运行)。但是在运行 api 级别 10 的设备时出现以下错误。
java.lang.NoSuchMethodError: android.support.v7.widget.Toolbar.animate
布局xml部分是
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#ff6d7fe2"
app:contentInsetEnd="0dp">
</android.support.v7.widget.Toolbar>
我没有将工具栏设置为支持操作栏。为什么即使使用 android.support.v7.widget.Toolbar 也会出现此错误?
【问题讨论】:
标签: android android-support-library android-toolbar