如何调整按钮内图像的大小?
我正在创建一个比例 UI,问题是 - 通过不同的 UI 分辨率,UI 组件会获得不同的形状。我使用的是图像文本按钮,不同的分辨率具有不同的尺寸。我可以这样做,使按钮内的图像调整大小也根据按钮的宽度/高度成比例吗? (目前图像不会改变其尺寸,只是隐藏了其中的某些部分)。
这是 xml-sorce,我用于此类按钮:
<Button
android:id="@+id/today"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/today"
android:drawablePadding="0sp"
android:gravity="center_horizontal|bottom"
android:textSize="8sp"
android:text="@string/today"
android:onClick="getRSSNews"
/>
I'm creating a proportional UI, the thing is that - by different UI resolutions the UI-components get different shapes. I'm using image-text button, which for different resolutions have different dimensions. Could I do so, that the image inside the button resize also proportional depending on button's width/height? (currently the image doesn't change its dimensions and just some parts of it are hidden).
Here is the xml-sorce, I'm using for such kind of button:
<Button
android:id="@+id/today"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/today"
android:drawablePadding="0sp"
android:gravity="center_horizontal|bottom"
android:textSize="8sp"
android:text="@string/today"
android:onClick="getRSSNews"
/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试创建 mdpi 和 ldpi 可绘制对象(具有相同的名称),看看它是如何工作的。
Try to create mdpi and ldpi drawables too (with same name) and see how will that work.