单击时android组件的掩码
我想在android中获得这种效果,我尝试设置布局的背景,但没有成功,这就像在布局的元素上加了一个面具。例如,当您单击google play上的按钮时,如下所示: 当你们点击它时,蓝色按钮上会有一个遮罩 有人能帮我吗 多谢各位单击时android组件的掩码,android,layout,Android,Layout,我想在android中获得这种效果,我尝试设置布局的背景,但没有成功,这就像在布局的元素上加了一个面具。例如,当您单击google play上的按钮时,如下所示: 当你们点击它时,蓝色按钮上会有一个遮罩 有人能帮我吗 多谢各位 我做了以下工作,创建了带有图像和文本的布局 <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravi
我做了以下工作,创建了带有图像和文本的布局
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/android" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="APP" />
</LinearLayout>
并创建框架布局
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_default"
android:clickable="true">
<include
android:layout_gravity="center_vertical"
layout="@layout/test1" />
</FrameLayout>
但只改变了背景,图像和文本不会被放置在遮罩上。我做错什么了吗?我想到的第一件事就是实施这种影响: 1.使用图标和文本(示例中的android图标和
应用程序
文本)创建布局(线性/相对
)
2.将两个维度的内容包装设置为wrap content
3.将此布局放在FrameLayout
内
4.在此框架布局中添加一个按钮,并将其设置为匹配父项
,为此按钮创建一个如下选择器,并将其作为背景应用:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:state_pressed="true"
android:drawable="@drawable/botton_shape_pressed" />
<!-- focused -->
<item android:state_focused="true"
android:drawable="@drawable/botton_shape_selected" />
<!-- default -->
<item android:drawable="@drawable/botton_shape_released" />
5。为按下的纹理创建半透明的蓝色纹理。对于其他两个状态,应用完全透明纹理。这将导致你寻找的面具效果。我想到的第一件事就是实施这种效果:
1.使用图标和文本(示例中的android图标和应用程序
文本)创建布局(线性/相对
)
2.将两个维度的内容包装设置为wrap content
3.将此布局放在FrameLayout
内
4.在此框架布局中添加一个按钮,并将其设置为匹配父项
,为此按钮创建一个如下选择器,并将其作为背景应用:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:state_pressed="true"
android:drawable="@drawable/botton_shape_pressed" />
<!-- focused -->
<item android:state_focused="true"
android:drawable="@drawable/botton_shape_selected" />
<!-- default -->
<item android:drawable="@drawable/botton_shape_released" />
5。为按下的纹理创建半透明的蓝色纹理。对于其他两个状态,应用完全透明纹理。这将导致遮罩影响您的搜索。能否显示您尝试实现的屏幕截图?链接图像:能否显示您尝试实现的屏幕截图?链接图像: