【问题标题】:how can i give shadow to the com.google.android.material.textfield.TextInputLayout?如何给 com.google.android.material.textfield.TextInputLayout 提供阴影?
【发布时间】:2020-06-09 04:38:45
【问题描述】:

我尝试了提升,但没有在 TextInputLayout 的上部获得阴影。我想得到如下图所示的阴影:

有什么办法可以得到这个影子吗?

【问题讨论】:

    标签: android material-design shadow android-textinputlayout


    【解决方案1】:

    如何给 com.google.android.material.textfield.TextInputLayout 提供阴影?

    您可以将TextInputLayout 包裹在Cardview

    示例代码

    <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="20dp"
            app:cardElevation="10dp">
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/textField"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="User name">
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
    
            </com.google.android.material.textfield.TextInputLayout>
        </androidx.cardview.widget.CardView>
    

    【讨论】:

    • 我可以在 android 中使用 dp 或任何其他方式获得响应式文本大小或边距、填充、高度吗? @尼莱什
    • 这会导致错误视图(setError)被 CardView 包裹起来。
    猜你喜欢
    • 2013-02-26
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 2017-04-24
    • 2018-03-01
    • 2018-07-19
    • 2013-10-07
    • 1970-01-01
    相关资源
    最近更新 更多