I have a weird problem. When I am doing this:
btnSleeping.setImageDrawable(getResources().getDrawable(
R.drawable.selector_sleeping_on));
the image is smaller than when I am doing this: btnSleeping.setImageDrawable(getResources().getDrawable(
R.drawable.sleeping_on));
sleeping_on is an image and selector_sleeping_on is a selector.
this is my selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_sleeping_on" android:state_pressed="false"/>
<item android:drawable="@drawable/btn_sleeping" android:state_pressed="true"/> <!-- default -->
I have the sleeping_on and sleeping_off images only in “drawable-xhdpi”.
Why is it that the selector is not appearing the same size as a normal imageViewand how can I make them the same size?
One Thing can be the image it self are of different size in this case which you are talking about,
And one more thing you can do is you can fix the size of the selector too.
Following is snippet to fix the size.
Note : Width and Height values you can change as you want.