A
A
Andrey Golikov2015-03-01 16:30:26
Android
Andrey Golikov, 2015-03-01 16:30:26

Why is android:elevation not working?

I am developing a calculator for Android, and when creating markup for round clocks, I ran into a problem, when specifying android:elevation - it does not draw a shadow. Where is the mistake?
Development environment -
63555eee89fe464390d614ab80edb3d9.PNG
Emulator -
8db739d979c14c768f13cb53b84a6c0f.PNG
XML ​​markup -

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context=".MainActivity"
    tools:deviceIds="wear_round"
    android:id="@+id/round_activity_main"
    style="@style/AppTheme"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true">

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:id="@+id/frameLayout"
        android:elevation="10sp"
        android:layout_alignParentEnd="true">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="40sp"
            android:gravity="center"
            android:maxLines="2"
            android:id="@+id/tvResult"
            android:textStyle="bold"
            android:text=""
            android:fontFamily="sans-serif-light"
            style="@style/AppTheme"
            android:layout_marginLeft="40sp"
            android:layout_marginRight="40sp"
            android:layout_marginTop="20dp" />

    </FrameLayout>

    <android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pagerRound"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        style="@style/AppTheme"
        android:layout_below="@+id/frameLayout" />

</RelativeLayout>

If you put android:elevation on the TextView - the shadow will be visible on the device.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marat S, 2015-03-03
@aratj

you can try parent RelativeLayout - set padding
and android:clipToPadding="false"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question