gpt4 book ai didi

android - 为什么我的 TextInputLayout 的 outLine 框没有出现?

转载 作者:行者123 更新时间:2023-12-02 03:57:28 25 4
gpt4 key购买 nike

我想用大纲框包裹我的编辑文本,所以我使用 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>

它的外观

我想要它:

最佳答案

您可以设置 TextInputLayout 的样式:

Widget.MaterialComponents.TextInputLayout.OutlinedBox

这应该可以完成任务。

简单的例子:

<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>

关于android - 为什么我的 TextInputLayout 的 outLine 框没有出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54167788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com