Android 视图从其父视图获取其可绘制状态(按下等…)
我有一个ListView,其中每个列表项都是基于RelativeLayout的自定义布局,它是可单击的,并且有一个自定义选择器。此外,它还有一个子相对论窗口,也可以单击,并且有自己的选择器 大概是这样的:Android 视图从其父视图获取其可绘制状态(按下等…),android,android-layout,css-selectors,Android,Android Layout,Css Selectors,我有一个ListView,其中每个列表项都是基于RelativeLayout的自定义布局,它是可单击的,并且有一个自定义选择器。此外,它还有一个子相对论窗口,也可以单击,并且有自己的选择器 大概是这样的: --------------- | | | ___ | | | | | --------------- 一切都运行得很好,但问题是,当我单击父相对布局时,子选择器假设父选择器的状态。我试着设置 android:dupli
---------------
| |
| ___ |
| | | |
---------------
一切都运行得很好,但问题是,当我单击父相对布局时,子选择器假设父选择器的状态。我试着设置
android:duplicateParentState="false"
但一切都没有改变
有什么想法吗?提前感谢能否显示ListView项目和选择器的代码?在我看来,你在实施时犯了一些错误。下面是我的项目及其选择器示例。这对我来说很好: 视频,我的实现工作原理:>单击打开
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="40dp"
android:background="@drawable/relative_selector">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="100dp"
android:background="@drawable/child_selector_1"
android:clickable="true">
<RelativeLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="@drawable/child_selector_2"
android:clickable="true"/>
</RelativeLayout>
</RelativeLayout>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<solid android:color="@android:color/holo_blue_bright" />
</shape>
</inset>
</item>
</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed state -->
<item android:state_pressed="true">
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<solid android:color="@android:color/holo_orange_dark" />
</shape>
</inset>
</item>
<!-- focused state -->
<item android:state_focused="true">
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<solid android:color="@android:color/holo_orange_dark" />
</shape>
</inset>
</item>
<!-- normal state -->
<item>
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<solid android:color="@android:color/holo_red_dark" />
</shape>
</inset>
</item>
</selector>