jac*_*ast 2 layout android imagebutton
我有这个小布局我定义插入我的应用程序的每个页面:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@null"
android:src="@drawable/sa_info"
android:layout_alignParentRight="true"/>
Run Code Online (Sandbox Code Playgroud)
我的sa_info.png是118x118,但我希望它在屏幕上显得更小.如果我尝试将图像按钮的宽度和高度设置为所需的大小(比方说48dp),当我运行应用程序时生成的图像被裁剪到中心:

因此,我必须获得所需结果的唯一方法是将图像本身缩放到所需的分辨率.我做错了什么,有更好的方法吗?
Ale*_*lex 12
尝试添加
android:scaleType ="fitCenter" - > http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
android:adjustViewBounds ="true" - >如果希望ImageView调整其边界以保持其drawable的纵横比,请将此设置为true.
| 归档时间: |
|
| 查看次数: |
4514 次 |
| 最近记录: |