1. 如果想设置图片固定大小,又想保持图片宽高比,需要如下设置:
1) 设置AdjustViewBounds为true;
2) 设置maxWidth、MaxHeight;
3) 设置设置layout_width和layout_height为wrap_content。
2. 很多时候,我们设置图片往往要给图片设置透明度。src和background不同,设置图片透明度的方法也略有区别。
当我们是用src来设置图片的时候,我们在代码中直接就可以通过
myImageView.setAlpha(int alpha)来设置;
而如果是通过background来设置图片的话,我们就要先取得它的background然后再设置:myImageView.getBackground().setAlpha(int alpha)。
3. 我们要设置多选框的大小,并不能单纯地通过设置CheckBox的android:layout_width和android:layout_height属性来设定(如果只是这样的设定,大家不妨试一试,只能显示多选框的一部分形状,而不是把整个多选框等比的缩放),而是需要为它设置一个样式,并在样式中为它设置图片,例如:
<style name="gl_task_checkbox"
parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/图片名</item>
</style>
这样的话CheckBox才能按照我们设定的大小来显示。