如何调整按钮内图像的大小?

发布于 2024-11-18 15:35:17 字数 543 浏览 6 评论 0原文

我正在创建一个比例 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别理我 2024-11-25 15:35:17

尝试创建 mdpi 和 ldpi 可绘制对象(具有相同的名称),看看它是如何工作的。

Try to create mdpi and ldpi drawables too (with same name) and see how will that work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文