如何使在一个线性布局的连锁反应,没有覆盖其子项上的背景色? [英] How to make a ripple effect over a linear layout, without overriding the background color on its children?

查看:300
本文介绍了如何使在一个线性布局的连锁反应,没有覆盖其子项上的背景色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个LinearLayout中,看起来像这样。

I have a LinearLayout that looks like this.

我希望每个行点击。在的LinearLayout code为行看起来是这样的:

I want each row to be clickable. The LinearLayout code for a row looks like this:

    <LinearLayout
        style="@style/home_menu_item_container"
        android:id="@+id/home_menu_acronyms_button"
        >
        <ImageView
            style="@style/home_menu_item_left"
            android:background="@color/greyLight"

            />
        <TextView
            style="@style/home_menu_item_right"
            android:text="@string/home_menu_option_2"
            android:background="@color/grey"
            />
    </LinearLayout>

我怎样才能添加在整个行扩展(父)产生连锁反应 - 该行不只是一个孩子的看法?这里最棘手的部分是让纹波去了两个彩色一行。

How can I add a ripple effect that expands over the entire row (parent) - not just one child view in the row? The tricky part here is to let the ripple go over the two colored row.

推荐答案

这是一个有点复杂,那是你需要的,但我不认为还有另一种方式,...

你需要把你的ImageView成的ListView 让每一个 ImageView的是一个列表项,然后你可以设置纹波,但你还需要设置 drawSelectorOnTop =真正的否则将无法正常工作

It is a little bit complicated for that what you need but I don't think there is another way,...
You need to put your ImageView's into a ListView so that every ImageView is a ListItem and then you can set the ripple but you also need to set drawSelectorOnTop="true" otherwise it won't work correctly

这篇关于如何使在一个线性布局的连锁反应,没有覆盖其子项上的背景色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆