@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
initView();
View contentView = inflater.inflate(R.layout.fragment_auto_raise, container, false);
unbinder = ButterKnife.bind(this, contentView);
return contentView;
}
private void initView() {
Window window = getDialog().getWindow();
/** 去4.4,5.1空Title */
window.requestFeature(Window.FEATURE_NO_TITLE);
//设置弹出动画
WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
params.windowAnimations = R.style.Animation_Bottom_Rising;
//设置宽高自适应,去掉左右两侧边距
window.getDecorView().setPadding(0, 0, 0, 0);
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = (int) (DisplayUtils.getInstance(getActivity()).getScreenHeight() * 0.9);
window.setAttributes(params);
//点击外部可以取消
getDialog().setCanceledOnTouchOutside(true);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
动画文件
<style name="Animation.Bottom.Rising" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/slide_in_bottom</item>
<item name="android:windowExitAnimation">@anim/slide_out_bottom</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/accelerate_decelerate"
>
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%p"
android:toYDelta="0" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="0.95"
android:toAlpha="1" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0"
android:toYDelta="100%p" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1"
android:toAlpha="0.95" />
</set>
2837

被折叠的 条评论
为什么被折叠?



