Я хочу обернуть свой текст для редактирования контурным окном, поэтому я использую TextInputLayout, но контурное окно не появляется, когда я делаю свой диалог в полноэкранном режиме.
я обнаружил, что проблема в том, что я делаю (домашнее задание) полноэкранный режим, используя эту строку кода:
setStyle(STYLE_NO_TITLE,R.style.DialogHomework);
вот мой домашний диалог xml:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/AppTheme"
android:fitsSystemWindows="true"
style="@android:style/Theme.NoTitleBar.Fullscreen"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Button
android:id="@+id/cancelHomework"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="24dp"
android:background="@drawable/circle_button"
android:text="Cancel"
android:textColor="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/addHomework" />
<android.support.design.widget.TextInputLayout
android:id="@+id/hw_dialog_title_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/hw_dialog_title_margin_start"
android:layout_marginLeft="@dimen/hw_dialog_title_margin_start"
android:layout_marginTop="@dimen/hw_dialog_title_margin_top"
android:layout_marginEnd="@dimen/hw_dialog_title_margin_end"
android:layout_marginRight="@dimen/hw_dialog_title_margin_end"
app:boxBackgroundColor="@android:color/transparent"
app:boxBackgroundMode="outline"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:boxStrokeColor="@color/colorPrimaryDark"
app:boxStrokeWidth="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hw_dialog_material">
<EditText
android:id="@+id/hw_dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName"
android:hint="@string/hw_dialog_title_hint"
android:textColor="@color/colorPrimary" />
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="@+id/hw_dialog_material"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/hw_dialog_material_margin_start"
android:layout_marginLeft="@dimen/hw_dialog_material_margin_start"
android:layout_marginTop="@dimen/hw_dialog_material_margin_top"
android:layout_marginEnd="@dimen/hw_dialog_material_margin_end"
android:layout_marginRight="@dimen/hw_dialog_material_margin_end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.TextInputLayout
android:id="@+id/hw_dialog_homework_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/hw_dialog_homework_margin_start"
android:layout_marginLeft="@dimen/hw_dialog_homework_margin_start"
android:layout_marginTop="@dimen/hw_dialog_homework_margin_top"
android:layout_marginEnd="@dimen/hw_dialog_homework_margin_end"
android:layout_marginRight="@dimen/hw_dialog_homework_margin_end"
android:layout_marginBottom="@dimen/hw_dialog_homework_margin_bottom"
android:gravity="top"
app:boxBackgroundColor="@android:color/transparent"
app:boxBackgroundMode="outline"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:boxStrokeColor="@color/primaryDark2"
app:boxStrokeWidth="100dp"
app:layout_constraintBottom_toTopOf="@+id/addHomework"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hw_dialog_title_layout">
<EditText
android:id="@+id/hw_dialog_homework"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ems="10"
android:gravity="top"
android:hint="@string/homework_hint"
android:inputType="textMultiLine" />
</android.support.design.widget.TextInputLayout>
<include
android:id="@+id/toolBar"
layout="@layout/toolbar"
/>
<Button
android:id="@+id/addHomework"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:layout_marginEnd="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="50dp"
android:background="@drawable/circle_button"
android:text="@string/add"
android:textColor="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
код моего домашнего задания:
public class newHomeWork extends DialogFragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_TITLE,R.style.DialogHomework);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View dialog = inflater.inflate(R.layout.homework_dialog,container,false);
Toolbar toolbar = dialog.findViewById(R.id.toolBar);
toolbar.setTitleTextColor(getResources().getColor(R.color.colorPrimaryDark));
TextView textView =toolbar.findViewById(R.id.homeworkDialogTitle);
textView.setText("Add homework");
Button add = dialog.findViewById(R.id.addHomework);
Button cancel = dialog.findViewById(R.id.cancelHomework);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
return dialog;
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
return dialog;
}
@Override
public void onStart() {
super.onStart();
}
}
мой стиль DialogHomeWork:
<style name="DialogHomework" parent="Theme.AppCompat.Dialog">
<item name="windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowBackground">@color/colorPrimary</item>
<item name="android:background">@color/colorPrimary</item>
</style>
как это выглядит
как я хочу это: