加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 带选择器的FrameLayout前台

发布时间:2020-12-14 06:01:37 所属栏目:Java 来源:网络整理
导读:我有一个FrameLayout,我想通过选择器应用前景drawable,我试图实现“drawSelectorOnTop”,但为一个简单的布局 现在,当用户按“state_pressed”时,选择器不适用 这是我的代码: FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" andro
我有一个FrameLayout,我想通过选择器应用前景drawable,我试图实现“drawSelectorOnTop”,但为一个简单的布局

现在,当用户按“state_pressed”时,选择器不适用

这是我的代码:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:foreground="@drawable/cell_background_selector" >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#282828"
        android:paddingBottom="5dp" >
..
......
........
</RelativeLayout>
</FrameLayout>

这是我的选择码:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/video_blank" android:state_pressed="true"/>
     <item android:drawable="@drawable/fav_show"/>
</selector>

两个图像都存在,但FrameLayout始终将普通状态drawable应用为前景

解决方法

老问题,但是当我遇到类似的问题时,它是谷歌的第一个打击.

您是否为FrameLayout设置了OnClick侦听器?如果不是,则永远不会使用按下状态.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读