首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我在style中设置OutlinedBox时,TextInputLayout不工作

当我在style中设置OutlinedBox时,TextInputLayout不工作
EN

Stack Overflow用户
提问于 2020-07-06 16:59:26
回答 3查看 1.1K关注 0票数 0

处理布局添加的依赖项implementation 'com.google.android.material:material:1.1.0'后,它也不工作

代码语言:javascript
复制
   <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="20dp"
                android:layout_below="@+id/textView"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">

        <EditText
                android:id="@+id/editTextCode"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawablePadding="10dp"
                android:inputType="phone"
                android:maxLength="6"
                android:paddingStart="3dp"
                android:drawableLeft="@android:drawable/stat_sys_phone_call"
                android:gravity="start"
                />
    </com.google.android.material.textfield.TextInputLayout>`
EN

回答 3

Stack Overflow用户

发布于 2020-07-06 17:40:05

使用EditText的TextInputEditText实例。检查以下代码

代码语言:javascript
复制
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayoutName"          
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/textInputLayoutEditTextName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Name"
                    android:inputType="text"
                    android:text="Data" />

</com.google.android.material.textfield.TextInputLayout>
票数 0
EN

Stack Overflow用户

发布于 2020-07-06 18:27:15

使用startIconDrawable属性定义图标,并使用TextInputEditText而不是EditText

代码语言:javascript
复制
    <com.google.android.material.textfield.TextInputLayout
        app:startIconDrawable="@drawable/ic_add_24px"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        ..>

        <com.google.android.material.textfield.TextInputEditText
            android:inputType="phone"
            android:maxLength="6"
            android:paddingStart="3dp"
            />
    </com.google.android.material.textfield.TextInputLayout>

票数 0
EN

Stack Overflow用户

发布于 2020-07-10 11:25:27

代码语言:javascript
复制
//Got solution actually problem in style 

<style name="AppTheme" parent="**Theme.MaterialComponents.Light.DarkActionBar**">

//Changed parent theme to MaterialComponents its working well for me.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62752577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档