以下は私の FragmentActivity と DialogFragment です。カスタム AlertDialog を作成しようとしています。下の画像のように、部分的にそれを達成しました。カスタム AlertDialog の周りの白い領域を取り除くにはどうすればよいですか?
public class MainActivity extends FragmentActivity {
public int mStackLevel = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showDialog();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void showDialog(){
mStackLevel++;
FragmentTransaction ft = getSupportFragmentManager ().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag ("dialogg");
if(prev != null)
{
ft.remove(prev);
}
ft.addToBackStack(null);
DialogFragment df = AppWizard.newInstance(mStackLevel);
df.show(ft, "dialogg");
}
public void doPositiveClick() {
// Do stuff here.
showDialog();
}
public void doNegativeClick() {
// Do stuff here.
}
public static class AppWizard extends DialogFragment {
int mNum;
static AppWizard newInstance(int num){
AppWizard aw = new AppWizard();
Bundle args = new Bundle();
args.putInt("num", num);
aw.setArguments(args);
return aw;
}
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
mNum = getArguments().getInt("num");
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
int title = getArguments().getInt("num");
LayoutInflater lo = getActivity().getLayoutInflater();
View view = lo.inflate(R.layout.fragment_dialog, null);
final CharSequence[] items = {"Bir daha gösterme!"};
final boolean[] _selections = null;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(view);
return builder.create();
}
}
これが私のアラートダイアログレイアウトxml fragment_dialog.xmlです
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_dialog"
style="@style/AlertDialogCustom"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top|center"
android:orientation="vertical"
android:background="@android:drawable/alert_dark_frame" >
<TextView
android:id="@+id/dialog_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BLABLABLA"
android:textColor="@android:color/black"
/>
<TextView
android:id="@+id/dialog_header2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BLABLABLA2"
android:textColor="@android:color/black"
/>
<Button
android:id="@+id/dialog_button"
android:layout_width="125dp"
android:layout_height="50dp"
android:text="Click"
android:textColor="@android:color/background_dark"
android:textSize="8sp"
android:textStyle="bold|italic"
/>
</LinearLayout>