这里是我的代码:
public class MyDialogFragment extends DialogFragment {
public static MyDialogFragment newInstance() {
final MyDialogFragment fragment = new MyDialogFragment ();
return fragment;
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_FRAME, R.style.MyDialog);
}
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
WindowManager.LayoutParams windowParams = window.getAttributes();
windowParams.dimAmount = 0.50f;
windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(windowParams);
}
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.dialog, container, false);
/* some init code for TextView and buttons here */
return view;
}
styles.xml:
<style name="MyDialog" parent="CustomDialog"></style>
<style name="CustomDialog" parent="@android:style/Theme.Light.Panel" />
它不是在Nexus 4/5设备上复制,而是在Desire S(hdpi,480x800)上复制。
请问有人帮我解决这个问题吗?