我有两个图像视图。我已经为一张图像视图设置了背景,并为一张图像视图设置了 src 。但两者看起来不同,而且当我按背景设置的图像视图时,它没有显示选择。谁能解释为什么会发生这种情况?
<ImageButton android:layout_width="250dp"
android:layout_height="100dp"
android:background="@drawable/perm_group_camera"/>
<ImageButton android:layout_width="250dp"
android:layout_height="100dp"
android:adjustViewBounds="true"
android:src="@drawable/perm_group_calendar"/>
但两者看起来不同
首先,绘图不同。
其次,背景总是根据视图的大小进行缩放。
当我按设置背景的图像视图时,它不显示选择。谁能解释为什么会发生这种情况
选择效果是因为默认情况下背景是StateListDrawable http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html以不同的外观state_pressed
。您的自定义背景在所有州看起来都一样。您可以创建StateListDrawables
在 xml 中带有selector http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)