喜是提供宽度drawable.xml在绘制文件夹中定义的绘制和高度的反正。
例如:
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目的android:STATE_ pressed =真
机器人:可绘制=@可绘制/ button_ pressed/> < - !pressed - >
<项目安卓state_focused =真
机器人:可绘制=@可绘制/ button_focused/> <! - 集中 - >
<项目机器人:可绘制=@可绘制/ button_normal/> <! - 默认 - >
< /选择器>
我想指定的宽度和高度可能在某种程度上使用比例标签里面,我试过但是很奏效。这是我的code:
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目机器人:可绘制=@可绘制/ icon_ratingstar>
<规模安卓scaleWidth =20机器人:scaleHeight =20机器人:可绘制=@可绘制/ icon_ratingstar/>
< /项目>
< /选择器>
项目> 标签宽度和
高度
的绘制
:
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目的android:STATE_ pressed =真
机器人:宽=100dp
机器人:身高=20dp
机器人:可绘制=@可绘制/ button_ pressed/> < - !pressed - >
<项目安卓state_focused =真
机器人:宽=100dp
机器人:身高=20dp
机器人:可绘制=@可绘制/ button_focused/> <! - 集中 - >
<项目机器人:可绘制=@可绘制/ button_normal/> <! - 默认 - >
Hi is there anyway of providing width and height of a drawable defined in drawable.xml in drawable folder.
Example:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector>
I wanted to specify width and height maybe somehow using "scale" tag inside it which i tried but didnt worked. This is my code:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/icon_ratingstar">
<scale android:scaleWidth="20" android:scaleHeight="20" android:drawable="@drawable/icon_ratingstar" />
</item>
</selector>
解决方案
You can specify inside the <item>
tag the width
and height
of the drawable
:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:width="100dp"
android:height="20dp"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:width="100dp"
android:height="20dp"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->