亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Android“海拔”沒有顯示陰影

Android“海拔”沒有顯示陰影

一只名叫tom的貓 2019-08-15 14:21:28
Android“海拔”沒有顯示陰影我有一個ListView,每個列表項我希望它在它下面顯示一個陰影。我正在使用Android Lollipop的新高程功能在View上設置一個我想要投射陰影的Z,并且我已經使用ActionBar(技術上是Lollipop中的工具欄)有效地做到了這一點。我正在使用Lollipop的高程,但由于某種原因,它沒有在列表項下顯示陰影。以下是每個列表項的布局設置方式:<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:orientation="vertical"     style="@style/block"     android:gravity="center"     android:layout_gravity="center"     android:background="@color/lightgray"     >     <RelativeLayout         android:layout_width="300dp"         android:layout_height="300dp"         android:layout_marginLeft="40dp"         android:layout_marginRight="40dp"         android:layout_marginTop="20dp"         android:layout_marginBottom="20dp"         android:elevation="30dp"         >         <ImageView             android:id="@+id/documentImageView"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:scaleType="centerCrop" />         <LinearLayout             android:orientation="vertical"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:background="@color/alphared"             android:layout_alignParentBottom="true" >         </LinearLayout>     </RelativeLayout></RelativeLayout>但是,這是它如何顯示列表項,沒有陰影: 我也試過以下無濟于事:將高程設置為ImageView和TextViews本身而不是父布局。將背景應用于ImageView。用TranslationZ代替Elevation。
查看完整描述

3 回答

?
長風秋雁

TA貢獻1757條經驗 獲得超7個贊

如果你有一個沒有背景的視圖,這一行會對你有幫助

android:outlineProvider="bounds"

默認情況下,陰影由視圖的背景決定,因此如果沒有背景,也不會有陰影。


查看完整回答
反對 回復 2019-08-15
?
神不在的星期二

TA貢獻1963條經驗 獲得超6個贊

顯然,您不能只在視圖上設置高程并讓它出現。您還需要指定背景。

添加到我的LinearLayout的以下行最終顯示陰影:

android:background="@android:color/white"android:elevation="10dp"


查看完整回答
反對 回復 2019-08-15
  • 3 回答
  • 0 關注
  • 365 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號