i want to wrap my edit text with outline box , so i am using TextInputLayout , but the outline box doesn't appear when i make my dialog full screen .
i detected that the problem is because i am making (homework dialog) full screen using this line of code :
setStyle(STYLE_NO_TITLE,R.style.DialogHomework);
here is my homework dialog 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" />
my homework dialog code:
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();
}
}
my DialogHomeWork style :
<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>
how it appears

how i want it:

You can set the style for the TextInputLayout:
Widget.MaterialComponents.TextInputLayout.OutlinedBox
This should do the thing.
Simple example:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Test me">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
Change your styles.xml Theme.AppCompat.Light.NoActionBar to Theme.MaterialComponents.Light.NoActionBar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With