首页 > 解决方案 > 高程在 ContraintLayout 中不起作用

问题描述

我不知道为什么android:elevation不工作

我的代码:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorWhite"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".UI.Activity.ChatActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:elevation="2dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_default="percent"
        app:layout_constraintHeight_percent="0.07"
        app:layout_constraintStart_toStartOf="parent"
        android:gravity="center_vertical">

        <EditText
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="8"
            android:inputType="text"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_marginRight="5dp"
            android:background="@drawable/border_edit_text_messenger"
            android:textCursorDrawable="@color/colorWhite"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"/>

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.8"
            android:src="@drawable/ic_send"
            android:scaleType="centerInside"
            android:layout_marginRight="15dp"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp"/>
    </LinearLayout>

</android.support.constraint.ConstraintLayout>

标签: android

解决方案


在您将任何背景颜色设置为要设置高程的ViewGroup或之前,高程无法以某种方式起作用。View

android:background="@color/colorWhite"
android:elevation="2dp"

到上述 xml 中的 LinearLayout。


推荐阅读