有人知道我如何为图像按钮和微调器添加阴影和高程吗?
它的放置方式仅在Android Studio中有效。当我在具有android API 17的设备上运行时,它不起作用。
在Android Studio中,它看起来好像很高,但是当我在设备上运行时,它不起作用并且看起来像图像
这是我的xml布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="0.0"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:mapbox_cameraTargetLat="-36.84"
mapbox:mapbox_cameraTargetLng="174.76"
mapbox:mapbox_cameraZoom="16">
</com.mapbox.mapboxsdk.maps.MapView>
<ImageButton
android:id="@+id/btnNotifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="148dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/circle_button"
android:elevation="3dp"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btnProfileUser"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.019"
mapbox:srcCompat="@drawable/ic_notification"
tools:ignore="VectorDrawableCompat" />
<ImageButton
android:id="@+id/btnProfileUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/circle_button"
android:elevation="3dp"
android:padding="10dp"
app:layout_constraintBottom_toTopOf="@+id/btnNotifications"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.789"
mapbox:srcCompat="@drawable/ic_user"
tools:ignore="VectorDrawableCompat" />
<android.support.v7.widget.CardView
android:id="@+id/cardSpinner"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:elevation="3dp"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
app:cardCornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="@+id/mapView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.015">
<Spinner
android:id="@+id/spinTypeVehicle"
android:layout_width="190dp"
android:layout_height="match_parent"
android:paddingLeft="10dp" />
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
您正在使用android:elevation
,它不适用于api <21
此解决方案可能有效:How to implement the Material-design Elevation for Pre-lollipop