简体   繁体   English

向 TextInputLayout 添加高程不起作用

[英]Adding elevation to TextInputLayout is not working

I'm using the TextInputLayout and MaterialAutoCompleteTextView from Material Design's text fields to create a dropdown menu as follows:我正在使用 Material Design 文本字段中的TextInputLayoutMaterialAutoCompleteTextView创建一个下拉菜单,如下所示:

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/drop_down_menu"
    style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_marginEnd="8dp"
    android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar"
    app:boxBackgroundColor="@android:color/white"
    app:layout_constraintBottom_toBottomOf="@+id/text_view_1"
    app:layout_constraintEnd_toStartOf="@+id/button_1"
    app:layout_constraintTop_toTopOf="@+id/text_view_1">

    <com.google.android.material.textfield.MaterialAutoCompleteTextView
        android:id="@+id/auto_complete_options"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="none"
        android:paddingStart="8dp"
        android:paddingEnd="8dp" />
</com.google.android.material.textfield.TextInputLayout>

The problem is if I add android:elevation="4dp" to TextInputLayout , nothing changes.问题是如果我将android:elevation="4dp"添加到TextInputLayout ,没有任何变化。 Why is that?这是为什么? How do I add elevation to my TextInputLayout ?如何向我的TextInputLayout添加高程?

Currently there is no work around for elevation into text layouts.目前没有解决方法将提升到文本布局。 All you can do is put your text input layout in a card view and give elevation in it.您所能做的就是将您的文本输入布局放在卡片视图中并在其中给出高度。 That is how you can achieve it.这就是你可以实现它的方法。

<androidx.cardview.widget.CardView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:clipToPadding="false"
        android:elevation="8dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM