Вы можете использовать DialogFragment
и настроить макет соответствующим образом.
public class CustomDialogFrag extends DialogFragment{
static FragmentManager fragmentManager;
public static CustomDialogFrag showDialog(FragmentManager fm){
CustomDialogFrag customDialogFrag=new CustomDialogFrag();
fragmentManager=fm;
return customDialogFrag;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
View view = getActivity().getLayoutInflater().inflate(R.layout.dialogfrag_layout, null);
alertDialogBuilder.setView(view);
setupUI(view);
alertDialogBuilder.setTitle("Notification Message");
alertDialogBuilder.setIcon(R.drawable.notificationicon);
alertDialogBuilder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialogBuilder.create();
}
void setupUI(View view){
TextView textViewOne=(TextView)view.findViewById(R.id.txtEventAlias);
TextView textViewTwo=(TextView)view.findViewById(R.id.txtTime);
TextView textViewThree=(TextView)view.findViewById(R.id.txtLogMessage);
textViewOne.setText("Text 1");
textViewTwo.setText("Text 2");
textViewThree.setText("Text 3");
}
}
И dialogfrag_layout.xml будет
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/margin_10"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtEventAlias"
android:text="Sample"
android:textColor="@android:color/darker_gray"
android:textSize="@dimen/textSizeMedium"
android:padding="@dimen/margin_10"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtTime"
android:text="Sample"
android:textColor="@android:color/darker_gray"
android:textSize="@dimen/textSizeMedium"
android:padding="@dimen/margin_10"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtLogMessage"
android:text="Sample"
android:textColor="@android:color/darker_gray"
android:textSize="@dimen/textSizeMedium"
android:padding="@dimen/margin_10"
/>
</LinearLayout>
Для вызова этого диалогового окна из Fragment
:
DialogFragment dialogFragment=CustomDialogFrag.showDialog(getFragmentManager());
dialogFragment.show(getActivity().getFragmentManager(), "tag");
Ваш вопрос каким-то образом направлен на окно самого диалога? В MATCH_PARENT и? Что-то похожее на это - http://stackoverflow.com/questions/11613825/how-to-create-dialog-which-will-be-full-in-horizontal-dimension -? –
Вы также можете попробовать добавить ***- true
***, http://stackoverflow.com/questions/9859220/full-screen-in-customize-theme –
Извините. Я не получил его. Я загрузил скриншот того, что получаю. –