我想加載一個DialogFragment通過單擊recyclerView項目與動畫,但在谷歌搜索小時我不能這樣做。 Recyclerview處於viewPager的frega中。 的dialogFregment是這樣的:動畫與對話框片段Android
public class adsDialogFregment extends DialogFragment {
public adsDialogFregment(){}
public static adsDialogFregment newInstance(HashMap<String,String> map) {
//HashMap<String,String> map= new HashMap<String, String>();
Bundle args = new Bundle();
args.putSerializable("Map", map);
adsDialogFregment fragment = new adsDialogFregment();
fragment.setArguments(args);
return fragment;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_dialog_show_ads,container,false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
TextView txtTitle = (TextView)view.findViewById(R.id.txtAdTitle);
HashMap<String,String> map= (HashMap<String, String>) getArguments().getSerializable("Map");
txtTitle.setText(map.get("title"));
}
@Override
public void onResume() {
/*ViewGroup.LayoutParams params=getDialog().getWindow().getAttributes();
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
getDialog().getWindow().setAttributes((WindowManager.LayoutParams)params);*/
super.onResume();
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getDialog().getWindow().getAttributes().windowAnimations= R.style.dialog_slide_animation;
}
,這些都是動畫:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="2000"
android:fillAfter="false"
android:fromXScale="0.5"
android:fromYScale="0.5"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="-90%"
android:toXScale="1.0"
android:toYScale="1.0" />
<translate
android:duration="3000"
android:fromXDelta="-200"
android:fromYDelta="-200"
android:toXDelta="0"
android:toYDelta="0" />
</set>
和
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="20000"
android:fillAfter="false"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="-90%"
android:startOffset="200"
android:toXScale="0.5"
android:toYScale="0.5" />
<translate
android:duration="30000"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="-200"
android:toYDelta="-200" />
</set>
和風格是:
<style name="dialog_slide_animation">
<item name="android:windowEnterAnimation">@anim/slidestart</item>
<item name="android:windowExitAnimation">@anim/slideend</item>
</style>
但:
dialogFregment.show(fm, "title");
不顯示爲動畫對話框。 我想在其他問題都解決方案,但他們沒有工作對我來說
問候
檢查出最佳答案(收到獎金的那個):http://stackoverflow.com/questions/13402782/show-dialogfragment-with-animation-growing-from-a-point –
不適用於DialogFragment 。在@VeneetReddy之前進行測試 – Hamed