我似乎无法在我的 DialogFragment/AlertDialog 上正确应用主题。
这是代码:
protected static class TabRenameDialogFragment extends DialogFragment
{
public static TabRenameDialogFragment newInstance(long tabId, CashierActivity ca) {
// create new dialogfragment and initialize items
TabRenameDialogFragment trdf = new TabRenameDialogFragment();
Bundle b = new Bundle();
b.putLong("TAB_ID", tabId);
trdf.setArguments(b);
return trdf;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final DialogFragment fm = this;
// set data
final long id = getArguments().getLong("TAB_ID");
return new AlertDialog.Builder(getActivity(), R.style.Theme_Styled_Dialog)
// .setIcon(R.drawable.alert_dialog_icon)
.setTitle("Rename " + cTabName)
.setView(view)
.setCancelable(true)
.setPositiveButton("Set",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}
).setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// nothing!
}
})
.create();
}
}
我正在使用 AlertDialog.Builder() 的 2 参数构造函数来设置主题;它正确设置了主题,但对话框片段本身周围出现了一个奇怪的边框。我认为这是因为我在 DialogFragment 中设置了 AlertDialog 的主题,但我不知道如何摆脱外部部分。我已经尝试将 DialogFragment 上的样式设置为 STYLE_NO_FRAME 等。
提前致谢。
编辑:
以下是我正在应用的样式:
<style name="Theme.Styled.Dialog" parent="@style/Theme.Sherlock.Light.Dialog">
<item name="dropDownListViewStyle">@style/Widget.Styled.DropDownListStyle</item>
<item name="android:dropDownListViewStyle">@style/Widget.Styled.DropDownListStyle</item>
<item name="android:windowTitleStyle">@style/DialogWindowTitle.Styled</item>
<item name="android:textColorPrimary">@color/bg_color_main</item>
<item name="android:textColorPrimaryInverse">@color/bg_color_main_dark</item>
</style>
<style name="DialogWindowTitle.Styled" parent="@style/DialogWindowTitle.Sherlock.Light">
<item name="android:textAppearance">@style/TextAppearance.Styled.DialogWindowTitle</item>
</style>
<style name="TextAppearance.Styled.DialogWindowTitle" parent="@style/TextAppearance.Sherlock.Light.DialogWindowTitle">
<item name="android:textColor">@color/bg_color_main</item>
</style>