java如何在安卓中对相对布局产生连锁反应?
我已经使用相对布局为安卓中的卡视图创建了自定义按钮,并通过<;包括布局功能。一切都很好,我只是想知道如何在点击时产生连锁反应
这是我的密码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent">
<FrameLayout
安卓:layout_width="125dp"
安卓:layout_height="30dp"
安卓:background="@color/colorPrimary"
安卓:layout_gravity="center_horizontal"
安卓:focusableInTouchMode="true">
<TextView
安卓:layout_width="125dp"
安卓:layout_height="30dp"
安卓:fontFamily="@font/questa"
安卓:text="Know More"
安卓:gravity="center"
安卓:textAllCaps="false"
安卓:textColor="#ffffff">
</TextView>
</FrameLayout>
</RelativeLayout>
包括布局代码:
<include
安卓:id="@+id/btnViewDetails"
style="@style/CardView.Button"
layout="@layout/button"
安卓:layout_width="125dp"
安卓:layout_height="30dp"
安卓:layout_below="@+id/viewDivider"
/>
# 1 楼答案
你必须把
ripple
添加到你的背景中假设您有这样一个
ripple
文件,文件名为drawable
中的ripple
:***第一个
item
给你的component
或button
添加效果,第二个item
表示你没有点击button
drawable_all_rows
然后你把它添加到你的
relative layout
背景中,如下所示:# 2 楼答案
我只用一行
# 3 楼答案
只需在RelativeLayout中添加3行代码
# 4 楼答案