Android Material Design-高程阴影不适用于嵌套内部布局

时间:2017-02-03 16:11:49

标签: android-layout material-design android-elevation

我正在编写一些带有几个嵌套布局的代码。由于我使用了材料设计,我也想设置高程。尽管使用最外层布局的元素,高程工作正常,但内部LinearLayout(嵌套在CoordinatorLayout内)的内容尽管设置了高程,但不会投射阴影。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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:orientation="vertical"
    android:background="@color/white"
    tools:context="com.joblesscoders.aditya.todolist.HomeActivity">

    <TextView
        android:layout_width="match_parent"
        android:id="@+id/count"
        android:text="Main Activity"
        android:textSize="20dp"
        android:elevation="5dp"
        android:textColor="@color/white"
        android:gravity="center_vertical"
        android:background="@color/colorPrimary"
        android:layout_height="50dp" />


    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/cly"
        android:background="@color/white"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        >
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/sv"
            android:background="@color/white"
            >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/lly"
                android:background="@color/white"
                android:orientation="vertical">

                <TextView
                    android:text="Task here"
                    android:id="@+id/tid"
                    android:textSize="40sp"
                    android:layout_marginBottom="5dp"
                    android:layout_width="match_parent"
                    android:elevation="4dp"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:layout_height="wrap_content" />
                <TextView
                    android:text="Task here"
                    android:id="@+id/tid"
                    android:textSize="40sp"
                    android:layout_marginBottom="5dp"
                    android:layout_width="match_parent"
                    android:elevation="4dp"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:layout_height="wrap_content" />
                <TextView
                    android:text="Task here"
                    android:id="@+id/tid"
                    android:textSize="40sp"
                    android:layout_marginBottom="5dp"
                    android:layout_width="match_parent"
                    android:elevation="4dp"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:layout_height="wrap_content" />
                <!-- More TextViews to suit purpose -->


            </LinearLayout>
        </ScrollView>
        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:src="@drawable/ic_add2"
            app:rippleColor="@color/white"
            android:id="@+id/fab"
            android:layout_gravity="bottom|end"
            />
    </android.support.design.widget.CoordinatorLayout>
</LinearLayout>

android studio designer视图中的此代码产生预期结果,即 Screenshot 1

TextViews在这里显示&#34;任务&#34;需要阴影,但是一旦我在Android 6.O自定义设备上运行它,页面就会变成: Screenshot 2

如果有人纠正我或对dos和don的建议,我将感激不尽。我是android编程的新手,这是我的第一个代码。所以,如果我犯了任何非常愚蠢的错误,请耐心等待。

0 个答案:

没有答案