private View rootView;
private int height;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getDialog().getWindow().setGravity(Gravity.BOTTOM);//Dialog处于页面的底部
getDialog().setCanceledOnTouchOutside(true);//点击Dialog外围可以消除Dialog
height = (int) (SysUtil.getScreenHeight(getActivity()) * 0.65);//DLG高度
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,height);//设置高宽
rootView=inflater.inflate(R.layout.dlg_product_item, null);
ButterKnife.bind(this, rootView);
return rootView;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
setStyle(DialogFragment.STYLE_NORMAL, R.style.dialog_fragment);
super.onCreate(savedInstanceState);
}
}
<style name="dlg_style" parent="android:Animation">
<item name="@android:windowEnterAnimation">@anim/dialog_in_bottom</item>
<item name="@android:windowExitAnimation">@anim/dialog_out_bottom</item>
</style>
<style name="dialog_fragment" parent="@android:style/Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowSoftInputMode">stateAlwaysHidden|adjustResize</item>
<item name="android:windowAnimationStyle">@style/dlg_style</item>
</style>
dialog_in_bottom文件
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="100%p" android:toYDelta="0%p"
android:duration="600"/>
</set>
dialog_out_bottom文件
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p" android:toYDelta="100%p"
android:duration="600"/>
</set>