标签: android-textinputlayout

TextInputLayout 在 ConstraintLayout 中无法正常工作

我是 ConstraintLayout 的新手。我试图设置 TextInputLayout 宽度以匹配父级,但它总是跳转到 365dp。而且我无法在另一个底部对齐 TextInputLayout。请帮我解决这个问题。 截屏

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="dcastalia.com.cook4me.LoginActivity"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">


<android.support.design.widget.TextInputLayout
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="39dp"
    android:layout_marginLeft="32dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginRight="32dp"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginStart="32dp"
    android:layout_marginEnd="32dp"
    app:layout_constraintHorizontal_bias="0.0"
    android:id="@+id/textInputLayout">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="hint" />
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
    android:layout_width="395dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    app:layout_constraintTop_toBottomOf="@+id/textInputLayout"
    app:layout_constraintRight_toRightOf="@+id/textInputLayout">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="hint" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

android android-textinputlayout android-constraintlayout

6
推荐指数
1
解决办法
3636
查看次数

你能在 textinputlayout 中添加一个 textview 或类似的东西吗?

我有一个使用大量 textinputlayouts 的应用程序,因为我喜欢它们创建的样式

在一个屏幕上,我正在显示一个对象的信息,我希望它也看起来像用户使用 textinputedittexts 输入的数据,上面的小标题和下面的数据

现在我有一个 textinputlayout,下面有一个禁用的 textinputedittext

有没有办法让 textinputlayout 下的 textview 以相同的样式显示?

提前感谢您提供的任何帮助

编辑:

作为旁注,这是我目前用来完全禁用编辑文本的内容

<android.support.design.widget.TextInputLayout
    android:id="@+id/name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/name"
        tools:text="This is where the name goes"
        android:inputType="none"
        android:clickable="false"
        android:cursorVisible="false"
        android:focusable="false"
        android:focusableInTouchMode="false" />
Run Code Online (Sandbox Code Playgroud)

我试图避免的不是在我尝试创建的每个视图中使用 clickable 和 inputtype 等,而是使用单个视图

所以除了创建一个以各种方式启动 unclickabke 的自定义编辑文本(如 NeverEnabledEditText),或者将所有这些属性添加到我的 xml 中,有没有办法做到以上几点?

android android-textinputlayout

6
推荐指数
1
解决办法
2526
查看次数

Android TextInputLayout提示与EditText提示重叠

我面临一个奇怪的问题,我有一个InputTextLayout和一个EditText,并且我正在尝试实现类似的功能(如下图所示)(来自材料设计指南的图像:https : //material.io/guidelines/components /text-fields.html#text-fields-layout),其中有两个单独的提示。我这样做是通过将android:hint添加到两个布局中。这可以正常工作,但是当焦点移开该位置时,“标签”将向下移动并与“占位符”文本重叠。(仅当用户未提供任何输入且编辑文本为空时,两个提示才重叠)。关于如何解决此问题的任何指示?

作为一项要求,我需要两个提示都存在,并且“标签”不应向下移至焦点更改。两种提示都应保持在原位

 <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Label">

        <android.support.v7.widget.AppCompatEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Placeholder"
            android:inputType="textCapWords"
            />

    </android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

android android-layout android-edittext android-textinputlayout textinputlayout

6
推荐指数
3
解决办法
4353
查看次数

以编程方式设置TextInputLayout主题

有没有一种方法可以在Android中以编程方式更改TextInputLayout的主题。如果我有以下TextInputLayout例如:

<android.support.design.widget.TextInputLayout
    android:id="@+id/label"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:paddingTop="16dp"
    android:theme="@style/TextInputLayoutTheme"
    app:errorTextAppearance="@style/Error">

    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/edit_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="8dp"
        android:paddingTop="8dp"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

我可以以android:theme="@style/TextInputLayoutTheme"编程方式将此行更改为另一个主题吗?

xml android android-layout android-textinputlayout

6
推荐指数
1
解决办法
2319
查看次数

TextFormField 失去焦点 - 颤动

我正在尝试解决我的应用程序中的表单验证问题。每次单击 TextFromField 时,焦点都会丢失并且键盘隐藏。我发现问题出在“_formKey”上。但我需要它来验证。如何解决?

代码片段:

  class _TodoCreateDetailPageState extends State<TodoPage> {
  @override
  Widget build(BuildContext context) {
    final GlobalKey<FormState> _formKey = new GlobalKey<FormState>();

    String _title = widget.todo == null ? "New TODO" : widget.todo.title;
    String _message;

    return new Scaffold(
      appBar: new AppBar(
        title: new Text(_title),
      ),
      floatingActionButton: new FloatingActionButton(
          child: new Icon(Icons.save), onPressed: null),
      body: new Padding(
          padding: new EdgeInsets.all(20.0),
          child: new Form(
              key: _formKey,
              child: new Column(
                children: <Widget>[
                  new TextField(
                    decoration: new InputDecoration(labelText: 'Title'),
                    onChanged: (String value) {
                      _title …
Run Code Online (Sandbox Code Playgroud)

dart android-textinputlayout flutter

6
推荐指数
3
解决办法
6017
查看次数

TextInputLayout 中的多行提示

我有一个很长的文本,需要按照要求浮动在编辑文本上。我在这里经历了很多这样的问题,但找不到正确的答案。我们怎样才能做到这一点?我试过在提示字符串中使用 '\n' 但它没有用。

android android-layout android-textinputlayout

6
推荐指数
1
解决办法
1719
查看次数

更改 TextInputLayout 的下划线颜色和浮动提示颜色

我在TextInputLayout主题中使用上述属性来使激活时的下划线颜色为绿色TextInputLayout

      <item name="colorControlActivated">#27e905</item>
Run Code Online (Sandbox Code Playgroud)

它工作正常,我得到以下结果

在此输入图像描述

但正如您所看到的,colorControlActivated也会影响浮动提示颜色。我需要不同的颜色来显示浮动提示。有什么办法可以这样做吗?

android android-styles android-textinputlayout

6
推荐指数
1
解决办法
6610
查看次数

MaterialComponents.TextInputLayout.OutlinedBox 它不能正常工作 boxBackgroundColor

我用材料。我将为 TextInputLayout 使用一种颜色作为背景,但类似于下面的颜色!提示背景未更改。我使用了样式并想进行更改,但没有奏效。在布局本身中,我尝试再次应用更改!如何解决这个问题?

笔记

图片中标签用户名的背景不透明,它覆盖了一些TextInputEditText

在此处输入图片说明

build.gradle 中

implementation 'com.google.android.material:material:1.1.0'
Run Code Online (Sandbox Code Playgroud)

风格

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="textAppearanceSubtitle1">@style/TextAppearance.App.Subtitle1</item>
        <item name="textAppearanceCaption">@style/TextAppearance.App.Caption</item>
        <item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.App.SmallComponent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar"/>

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light"/>


    <style name="TextAppearance.App.Subtitle1" parent="TextAppearance.MaterialComponents.Subtitle1">
        <item name="colorControlActivated">@color/white</item>
        <item name="android:colorControlActivated">@color/white</item>
    </style>

    <style name="TextAppearance.App.Caption" parent="TextAppearance.MaterialComponents.Caption">
        <item name="android:textColorTertiary">@color/white</item>
        <item name="android:textColorTertiaryInverse">@color/white</item>
        <item name="colorControlActivated">@color/white</item>
        <item name="android:colorControlActivated">@color/white</item>
    </style>

    <style …
Run Code Online (Sandbox Code Playgroud)

android material-design android-textinputlayout android-textinputedittext

6
推荐指数
1
解决办法
3214
查看次数

6
推荐指数
3
解决办法
1755
查看次数

切换密码字段jetpack compose

嗨,当用户单击查看密码按钮时,我正在尝试动态更改 visualTransformation。我可以设法过滤密码,但无法以纯文本显示。有什么想法吗?这是我到目前为止所得到的。

fun UserInputText(
    keyboardType: KeyboardType = KeyboardType.Text,
    onTextChanged: (TextFieldValue) -> Unit,
    textFieldValue: TextFieldValue,
    visualTransformation: VisualTransformation = VisualTransformation.None,
    borderColor: Color = editTextBorderColor,
    keyboardShown: Boolean,
    onTextFieldFocused: (Boolean) -> Unit,
    focusState: Boolean,
    placeholder: String = "",
    modifier: Modifier = Modifier
) {
    Box(
        modifier = modifier.border(
            width = 2.dp,
            color = borderColor,
            shape = RoundedCornerShape(16.dp)
        )
    ) {
        var lastFocusState by remember { mutableStateOf(FocusState.Inactive) }
        val focusRequester = FocusRequester()
        val focusRequesterModifier = Modifier.focusRequester(focusRequester)

        BasicTextField(
            value = textFieldValue,
            onValueChange = { onTextChanged(it) }, …
Run Code Online (Sandbox Code Playgroud)

android material-design android-textinputlayout android-jetpack-compose android-jetpack-compose-text

6
推荐指数
2
解决办法
2131
查看次数