Android 5.0 android: la elevación funciona para la vista, ¿pero no para el botón?
En las muestras de Android 5.0 del SDK Manager, está elElevationBasic
muestra. Muestra dosView
objetos: un círculo y un cuadrado. El círculo tieneandroid:elevation
ajustado a30dp
:
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout 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">
<View
android:id="@+id/floating_shape"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginRight="40dp"
android:background="@drawable/shape"
android:elevation="30dp"
android:layout_gravity="center"/>
<View
android:id="@+id/floating_shape_2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="25dp"
android:background="@drawable/shape2"
android:layout_gravity="center"/>
</FrameLayout>
En un Nexus 9, ejecutando la muestra tal cual, obtenemos una sombra paralela en el círculo:
Si cambiamos la clase de widget aButton
, dejando todos los demás atributos tal cual, perdemos la sombra paralela en el círculo:
Las preguntas:
Porque es elandroid:elevation
cambio de comportamiento? No puede ser debido al fondo, porque es el mismo fondo en ambos casos.
¿Qué clases admitenandroid:elevation
y cuales no? Por ejemplo, usandoTextView
en lugar deView
oButton
todavía nos da la sombra, por lo que este cambio de comportamiento no se introduce en elTextView
nivel, sino más bien en elButton
nivel.
Como se vio enesta pregunta desde ayer, como llegamosandroid:elevation
ser honrado en unButton
? Hay algunaandroid:allowElevationToWorkAsDocumented="true"
valor que tenemos que poner en un tema o algo?