问题描述
我想知道是否有一个选择的布局像有是可绘。
I was wanting to know if there is a selector for layouts like there is for drawables.
选择与绘制的例子:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected -->
<item android:drawable="@drawable/tab_library_clicked"
android:state_selected="true" />
<!-- When not selected -->
<item android:drawable="@drawable/tab_library_not_clicked" />
但是,它可能有这样的事情(低于此code并没有为我工作,但它应该给你什么,我试图完成一个想法):
But is it possible to have something like this (This code below didn't work for me but it should give you an idea of what I am trying to accomplish):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected -->
<item android:layout="@layout/tab_library_clicked"
android:state_selected="true" />
<!-- When not selected -->
<item android:layout="@layout/tab_library_not_clicked" />
推荐答案
我可能是错的,但我是pretty的肯定,这并不存在。
I might be wrong, but I'm pretty sure this doesn't exist.
最复杂,你就可以用XML一个选择做可能是使用的几可绘制合并到一个状态。
The most "sophisticated" you'll be able to do with a selector in XML probably is using a drawable layer list to combine several drawables onto one state.
另外,您可以尝试使用touch_down和touch_up事件以编程方式调用 setVisibility()
上的布局,但我想象中的表现会很差。
Alternatively you can try using the touch_down and touch_up events to programmatically call setVisibility()
on the layouts, but I imagine the performance will be very poor.
这篇关于Android的XML选择器布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!