好久没写了,直接上代码:
先上效果吧:正常图:如下:
然后点击右上角编辑:
从底部弹出一个框并挤压listview,即把listview推上面去了;
效果如下图:
然后上传代码:
/**
* 退出动画
*/
private void exitanimation() {
Animation animation = AnimationUtils.loadAnimation(
getActivity(), R.anim.dialog_exit);
linear_popcamera.clearAnimation();
linear_popcamera.setAnimation(animation);
linear_popcamera.setVisibility(View.GONE);
xListView_scan.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT, 1.0f));
linear_popcamera.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT, 0.0f));
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
/**
* 进入动画
*/
private void enteranimation() {
xListView_scan.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT, 1.0f));
linear_popcamera.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT, 0.0f));
Animation animation = AnimationUtils.loadAnimation(
getActivity(), R.anim.dialog_enter);
linear_popcamera.clearAnimation();
linear_popcamera.setAnimation(animation);
linear_popcamera.setVisibility(View.VISIBLE);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
view1挤压view2的核心在于改变weight, 即可视布局分布大小;
上面是进入和退出动画, 从底部往上弹出,从上面往下消失;
dialog_exit.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:toYDelta="100%p"
android:duration="300"
/>
</set>
dialog_enter.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="100%p"
android:duration="300"
/>
</set>
布局device_message_fragment.xml
<?xml version="1.0" encoding="utf-8"?><!--用于第一个fragment布局添加-->
<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:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.xlistview.XListView
android:id="@+id/xListView_scan"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:divider="#00000000"></com.xlistview.XListView>
<LinearLayout
android:id="@+id/linear_popcamera"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.0"
android:background="#404040"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:src="@drawable/btn_gongneng" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="功能选项"
android:textColor="@color/white"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/all_read_linear"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_bianji_yidu" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="标注已读"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/all_select_linear"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_bianji_quanxuan" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="全选"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/delete_linear"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/delete_message" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="删除"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>