MaterialComponents.TextInputLayout.OutlinedBox 它无法正常工作 boxBackgroundColor

2024-01-23

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

NOTE

的背景标签用户名图片中没有透明的 and it covers一些文本输入编辑文本

in 构建.gradle

implementation 'com.google.android.material:material:1.1.0'

in style

 <!-- 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 name="ShapeAppearance.App.SmallComponent" parent="ShapeAppearance.MaterialComponents.SmallComponent">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSize">16dp</item>
        <item name="colorControlActivated">@color/white</item>
        <item name="android:colorControlActivated">@color/white</item>
    </style>

in layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/gray"
  android:gravity="center"
  android:orientation="vertical"
  android:padding="32dp">

  <com.google.android.material.textfield.TextInputLayout
    android:id="@+id/linUsername"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="16dp"
    android:hint="@string/label_username"
    android:textColorHint="#AEB0C6"
    app:boxBackgroundColor="#33385E"
    app:boxStrokeColor="@color/red"
    app:endIconDrawable="@drawable/ic_clear_white_24dp"
    app:endIconMode="password_toggle"
    app:endIconTint="#AEB0C6"
    app:hintTextColor="#AEB0C6"
    app:startIconDrawable="@drawable/ic_info_outline_white_24dp"
    app:startIconTint="#AEB0C6">

    <com.google.android.material.textfield.TextInputEditText
      android:id="@+id/edtUsername"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="textPersonName"
      android:textColor="@color/white"
      android:textColorHint="@color/white"
      app:hintTextColor="#AEB0C6" />

  </com.google.android.material.textfield.TextInputLayout>


  <com.google.android.material.button.MaterialButton
    android:id="@+id/btnSelectText"
    android:layout_width="168dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="24dp"
    android:fontFamily="@font/iran_sans_mobile"
    android:text="login"
    android:visibility="visible"
    app:cornerRadius="@dimen/radiusButton" />
</LinearLayout>

您可以使用带边框的自定义编辑文本,以便您可以轻松设置所需的背景。例如尝试以下代码: 活动主文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="32dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="15dp"
            android:background="@drawable/boarder"
            android:paddingLeft="5dp"
            android:text="input"
            app:endIconMode="password_toggle"
            app:endIconTint="#EF0707" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="7dp"
            android:background="#fff"
            android:text="Label" />
    </RelativeLayout>

    <com.google.android.material.button.MaterialButton
        android:id="@+id/btnSelectText"
        android:layout_width="168dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:text="login"
        android:visibility="visible"
        app:cornerRadius="10dp" />
</LinearLayout>

边界.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke
        android:width="2dp"
        android:color="#03A6F0" />

    <corners android:radius="12dp" />
</shape>

另请参阅此处:自定义编辑带边框的文本 https://stackoverflow.com/questions/50619360/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MaterialComponents.TextInputLayout.OutlinedBox 它无法正常工作 boxBackgroundColor 的相关文章

随机推荐

  • 绕过 Rsync 提示“您确定要继续连接吗”

    如何绕过这个问题或添加一个自动回答这个问题的标志 因为我正在尝试编写一个脚本 并且这个问题不断停止 rsync 的过程 因为在提示时无法在脚本中回答这个问题 Set the StrictHostKeyChecking选项no 在配置文件中或
  • OpenCV-Python 中的简单数字识别 OCR

    我正在尝试在 OpenCV Python cv2 中实现 数字识别 OCR 它仅用于学习目的 我想学习 OpenCV 中的 KNearest 和 SVM 功能 我有每个数字 100 个样本 即图像 我想和他们一起训练 有一个样本letter
  • 通过 Java 使用 Selenium Webdriver 缺少 size() 选项

    一直在参加一些课程来提高我使用 Selenium Webdriver 的自动化技能 我没有size 方法作为尝试计算页面内链接数量时的一个选项 我缺少一些罐子吗 导入库 java public static void main String
  • SVG 坐标系 - 点与像素

    阅读通过SVG 1 1 规范 http www w3 org TR SVG11 coords html 我试图理解用于定义初始视口的单位与文档其余部分使用的单位之间的关系 如果视口最初是使用点定义的
  • 我的 $Foo ATL 解决方案中的 ($Foo)PS 项目有何用途?

    在MSVC中创建一个ATL项目似乎创建的不是一个而是两个项目 后者的名称与前者相同 但名称后附加了 PS 第二个项目的目的是什么 我如何判断我是否需要它 COM 支持跨两个不同的线程 两个不同的进程或两台不同的机器进行接口方法调用 这就是所
  • 当前单元格展开时折叠其他 UITableViewCell

    我正在努力扩展我的UITableViewCell我可以扩展细胞 但我想崩溃UITableViewCell哪些没有被选中 我在代码中尝试的内容 var expandedCells Int IBOutlet weak var tableView
  • 基于视图和单元格的 NSTableView

    Cocoa 中基于单元格的表格视图和基于视图的表格视图之间的主要区别是什么 我的理解是基于单元格的表格视图基本上用于显示字符串 基于视图用于自定义单元格 诸如拖动行 选择等用户事件可以在基于视图中处理 基于单元格的表格视图使用 object
  • 如何完全禁用LogCat暂停?

    我对新的 LogCat 及其暂停功能有一个大问题 当我想从中读取一些较旧的条目时 我喜欢暂停输出的想法 但有时我希望输出不间断 这样我就可以触摸手机 并通过读取输出来查看它的反应 所以令我非常沮丧的是 LogCat 经常完全暂停 暂停按钮被
  • 在 div 上使用“display:table-cell”有缺点吗?

    我想要实现的是拥有一个固定宽度的第一个 div 和一个流动的第二个 div 它将填充父 div 宽度的其余宽度 div class clearfix div style width 100px some content div div so
  • hsc2hs:使用 Haskell 改变 C 结构

    我正在尝试编写一个与 C 通信的 Haskell 程序 最终通过 GHC iOS 用于 iOS 我希望它将一个字符串从 C 传递到 Haskell 让 Haskell 处理它 然后通过 hsc2s 将一些数据类型从 Haskell 返回到
  • 如何在 Mahout 0.9 中实现 SlopeOne 推荐器?

    我是 Mahout 新手 正在尝试使用 0 5 版本的 Mahout in Action 早期的例子之一要求使用斜率一推荐器 Mahout 0 9 中还包含此推荐器吗 我查看了文档 但找不到它 也许它已经改名了 感谢您的帮助 Mahout
  • 当表没有行时,将表的可见性设置为 false(在报告服务中)

    如果表没有行 有没有办法将表的可见性设置为 false 我想在 Reporting Services 中隐藏没有行的表 将 NoRows 设置为 在这种情况下是不够的 因为仍然为表格留有空间 并且表格的某些格式仍然可见 我正在使用 Micr
  • 在 Python 中 - 解析响应 xml 并查找特定文本值

    我是 python 新手 在使用 xml 和 python 时遇到特别困难 我遇到的情况是这样的 我正在尝试计算一个单词在 xml 文档中出现的次数 很简单 但是 xml 文档是来自服务器的响应 是否可以在不写入文件的情况下执行此操作 尝试
  • Ansible,将字典合并为一次

    我有这个示例 yaml 文件 haproxy yml rules aa PHP53 url php53 1 aa my example com PHP55 url php55 1 aa my example com PHP56 url ph
  • 根据请求参数有条件地使用中间件express

    我正在尝试根据请求查询参数决定要使用的中间件 在主模块中我有这样的东西 app use function req res if req query something pass req res to middleware a else pa
  • 使用 __getattr__ 和 __setattr__ 功能实现类似字典的对象

    我正在尝试实施一个dict类似对象 可以访问 修改 getattr and setattr 为了方便我的用户使用 该类还实现了一些其他简单的功能 Using 这个答案 https stackoverflow com questions 33
  • 非灵活环境应用程序的自定义运行时?

    我不认为我的 gae python 应用程序具有灵活的环境 因为我多年前创建了它 现在我想尝试创建一个具有不同于 python 的运行时的模块 并使 python 应用程序与新的运行时 自定义运行时或其他运行时一起运行 也许混合 PHP 和
  • 将 IQueryable 类型转换为 Linq to Entities 中的接口

    我的泛型类中有以下方法 This is the class declaration public abstract class BaseService
  • Google Cloud 端点和 JWT

    我有一个基于 Google Cloud Endpoints 的 API 我想使用 JWT Json Web Tokens 进行授权 我可以为每个包含令牌的请求设置授权标头 并且它可以正常工作 我知道 Endpoints 使用此标头进行 Oa
  • MaterialComponents.TextInputLayout.OutlinedBox 它无法正常工作 boxBackgroundColor

    我用的是材料 我将使用 TextInputLayout 的颜色作为背景 但类似于下面的颜色 提示背景未更改 我使用了样式并想进行更改 但没有成功 在布局本身中 我尝试再次应用更改 如何解决这个问题 NOTE 的背景标签用户名图片中没有透明的