第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

安卓實(shí)現(xiàn)局部界面遮罩效果

標(biāo)簽:
Android

背景

列表展示数据时,有些数据因为失效了,需要灰化展示。但是因为每一行数据里面包含多个view(如包含用户姓名、性别等等信息),不方便对每个view进行灰化设置,所以需要一个遮罩层将整行遮盖来达到灰化效果。大致效果如下:


webp

解决方案

列表的item布局采用RelativeLayout或者ConstraintLayout,在layout中增加一个空的view(遮罩层),刚好能盖住其他view,默认设置为不可见。在adapter里根据数据的有效性设置是否打开这层遮罩层。

带遮罩的item布局文件样例如下:
其中maskLayer为遮罩层view,如下几点需要重点注意

  1. android:layout_height="30dp" 这个高度要设置为固定的值,必须刚好和view原本高度相同,不能设置为wrap_content或match_parent。所以此方案不适用于item的高度不固定的情况。

  2. android:background="#80F9F9F9" 设置遮罩层的颜色,前两位是透明度(00到FF,值越小越透明。)

  3. android:clickable="true"和android:focusable="true" 是为了屏蔽点击事件,让点击失效。

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tv_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:textColor="@android:color/black"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="TextView" />

    <View
        android:id="@+id/maskLayer"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="#80F9F9F9"
        android:clickable="true"
        android:focusable="true"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>



作者:程序园中猿
链接:https://www.jianshu.com/p/db078107fa0c


點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫(xiě)下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶(hù)
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專(zhuān)欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消