标签:android image-resizing imagebutton
如何防止ImageButton拉伸图像?
使用此代码段:
<ImageButton
android:src="@drawable/prediction"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_horizontal"
android:scaleType="centerInside"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:contentDescription="some description"
android:text="@string/predict"
local:MvxBind="Click ExecuteQueryCmd" />
我得到以下效果:
图像是64×64 png.
我想要的只是让ImageButton尊重它所分配的图像的原始宽度和长度,从而分辨率.基于similar post的建议是使用Button,将其背景设置为图像然后使用自定义选择器,但这听起来像是黑客.或者这是正确的方法吗?
解决方法:
它对我有用
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:contentDescription="some description"
android:scaleType="centerInside"
android:src="@drawable/ci_icon"
android:text="@string/predict"
local:MvxBind="Click ExecuteQueryCmd" />
将您的图像放在android:src属性中
标签:android,image-resizing,imagebutton 来源: https://codeday.me/bug/20190831/1774879.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。