Android:为小部件添加高程

时间:2016-08-08 19:37:13

标签: android layout widget

我正在尝试向窗口小部件布局添加高程。我在根布局中放置了android:elevation,我也尝试将它放在子相对布局中。

<RelativeLayout
    android:id="@+id/main_layout"
    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="@drawable/widget_background"
    android:elevation="30dp">

    <RelativeLayout
        android:id="@+id/widget_bad_data_text"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible">

        <ImageView
            android:id="@+id/widget_no_data_icon"
            android:layout_width="@dimen/widget_1x1_icon_width_height"
            android:layout_height="@dimen/widget_1x1_icon_width_height"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="@dimen/widget_1x1_margin_top"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/widget_no_data_icon"
            android:text="@string/widget"
            android:layout_centerHorizontal="true"
            android:fontFamily="sans-serif-light"
            android:textColor="@android:color/white"
            android:textSize="@dimen/widget_1x1"
            tools:ignore="UnusedAttribute,SpUsage" />

    </RelativeLayout>

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

您正在向基础容器添加elevation。为了能够看到高程效果,请将其边距设置为30dp