我通读了Android Dialog Design Guide。我想创建一个“新事件”样式对话框(该链接将您带到该部分)。但是我找不到任何关于它的信息。它是主题还是模板,还是我必须手动创建它?我觉得我看到了很多,所以我希望它是一些主题或模板。以前有人用过吗?提前谢谢。
编辑:我得到的风格是全屏幕,动作栏,标题和两个按钮(在这种情况下取消/保存)
编辑2:这是我的对话片段
public class Countdown extends DialogFragment {
public static final String COUNTDOWN_PREFS = "COUNTDOWN_PREFS";
private DatePicker datePicker;
private final Calendar calendar = Calendar.getInstance();
private final long MILLIS_PER_DAY = 60*60*24*1000;
private SimpleDateFormat dateFormat;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_countdown, container, false);
//setStyle(DialogFragment.STYLE_NORMAL, R.style.FullScreenDialog);
return v;
}
public interface CountdownDialogListener {
void onDialogPositiveClick(DialogFragment dialog);
void onDialogNegativeClick(DialogFragment dialog);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Dialog_NoActionBar);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
return builder.setMessage("Test").setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//((EnterPhoneNumberActivity)getActivity()).doPositiveClick();
}
}
)
.setNegativeButton("EDIT",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//((EnterPhoneNumberActivity)getActivity()).doNegativeClick();
}
}
).create();
}
@Override
public void onStart()
{
super.onStart();
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
getDialog().getWindow().setLayout(width, height);
}
}
答案 0 :(得分:1)
您只需更改AndroidManifest.xml中的主题
即可 <activity
android:theme="@style/Theme.AppCompat.Light.Dialog"
android:name=".dialogAcitvity >
</activity>
您也可以使用dialogFragment
编辑:
dialogFragment.java
@Override
public void onStart()
{
super.onStart();
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
getDialog().getWindow().setLayout(width, height);
}
将对话框设置为全屏
EDIT2:
MainActivity.java
FragmentManager fm = getSupportFragmentManager();
DialogFragment fragment = dialogFragment.newInstance();
fragment.setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Light );
fragment.show(fm,TAG_dialog);
通过设置为非对话框样式,它将填满全屏。似乎是最短路。
https://groups.google.com/forum/#!topic/android-developers/NDFo9pF8sHY