1
我在对话框布局中使用cachapa/ExpandableLayout,但我遇到了一些意想不到的动画。我的意思是,可扩展的布局不会平稳移动,而是突然移动。ExpandableLayout动画不平滑
正如你可以看到上面的图片,我把对话在使用Utils.setWindowGravity(getWindow(), Gravity.BOTTOM);
屏幕的底部。如果我将其更改为TOP,则动画的作品fine。但就我而言,我应该把它设置在底部。我该如何解决它?
RES /布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--other views-->
<net.cachapa.expandablelayout.ExpandableLayout
android:id="@+id/expand_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:el_duration="500"
app:el_expanded="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/name"
style="@style/EditText_BorderedMiddle_Grey_F"
android:layout_width="match_parent"
android:layout_weight="1"
android:hint="@string/dialog_categories_hintname"/>
<ImageView
android:id="@+id/submit"
style="@style/ImageView_FilledMiddle_Blue_F_50"
android:src="@drawable/ic_check_white_48dp"/>
</LinearLayout>
</net.cachapa.expandablelayout.ExpandableLayout>
<!--other views-->
</LinearLayout>
的Java
public class CategoriesDialog extends AppCompatDialog {
//other codes
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.setWindowGravity(getWindow(), Gravity.BOTTOM);
//...
}
@OnClick(R.id.add)
public void onAddClick() {
expandAdd.toggle();
}
}
public class Utils {
public static void setWindowGravity(Window window, int gravity) {
WindowManager.LayoutParams attributes = window.getAttributes();
attributes.gravity = gravity;
window.setAttributes(attributes);
}
}
尝试在顶部线性布局中添加animatelayoutchanges = true –
谢谢您的回答。我试过了,但还是不行。 –
检查你的自定义班级代码或库文档 –