java – 带选择器的FrameLayout前台

前端之家收集整理的这篇文章主要介绍了java – 带选择器的FrameLayout前台前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个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侦听器?如果不是,则永远不会使用按下状态.

原文链接:https://www.f2er.com/java/120443.html

猜你在找的Java相关文章