java - 如何使自定义布局的背景变暗?

标签 java android

我创建了一个扩展 View 组的自定义布局,以便实现类似于此视频 1:18 中的滑动菜单:https://www.youtube.com/watch?v=YeR7McJIltk

但是,我不知道如何在菜单滑入时使背景内容变暗。

最佳答案

你可以这样做:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1">
        //your views are here

    </LinearLayout>

    <View
        android:id="@+id/dim"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#cc000000" />

</RelativeLayout>

并使您的dim FrameLayout 仅在菜单打开时可见,在关闭时不可见

关于java - 如何使自定义布局的背景变暗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38584883/

相关文章:

java - 在 Eclipse 中每次运行之前关闭 Java 应用程序

Android : OpenGL 2. 0 第一人称相机

android - CursorAdapter 已弃用?

android - 如何使用 BluetoothHeadset API 获取蓝牙连接的设备

java - 使用身份验证从 JAVA 连接到 RServe

java - 正则表达式程序

java - Intellij 如何使用 spring boot 正确配置 hql。现在我得到 Persistence QL Queries are error-checked

java - Mapstruct-找不到没有源的属性的映射

android - AVD 解析速度非常慢

android - 为微调器添加过滤器并过滤微调器本身的数据