按下选择器不在imageVIew中工作

时间:2015-06-19 07:13:46

标签: android

我正在使用imageView的选择器来更改按下事件的图像。 但是当我按下它时,它不会改变图像。

这是选择器,

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item 
   android:state_pressed="true" 
   android:drawable="@drawable/fed_1" />
 <item 
   android:drawable="@drawable/fed" />
</selector>   

这是我的imageview,

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:src="@drawable/sel_fed" />

还尝试使用背景进行图像查看,但它无效。

3 个答案:

答案 0 :(得分:2)

你应该添加library('MASS') Sigma <- var(df) Means <- colMeans(df) simulation <- mvrnorm(n = 1000, Means, Sigma) 。你的imageView将是这样的

android:clickable="true"

答案 1 :(得分:0)

将您的src更改为background并将android:clickable="true"添加到ImageView

答案 2 :(得分:0)

您可以尝试此选择器

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

    <item android:drawable="@drawable/fed_1" android:state_selected="true"></item>
    <item android:drawable="@drawable/fed_1" android:state_pressed="true"></item>
    <item android:drawable="@drawable/fed"></item>

</selector>

在图像视图中将src更改为背景。

  android:background="@drawable/sel_fed"