调整图像大小按钮
我有一个放置图片的按钮...我必须尝试调整按钮内图像的大小...如何调整它的大小?我可以直接从xml代码中做到这一点吗? 这是 xml 代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:orientation="vertical"
android:layout_width="250dp"
android:layout_height="180dp"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:background="@color/white_trasparent"
android:weightSum="1">
<TextView
android:layout_height="wrap_content"
android:id="@+id/text"
android:textColor="@color/grey"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_marginLeft="15dp">
</TextView>
<Button
android:layout_width="wrap_content"
android:text="Drawable Top"
android:id="@+id/Button03"
android:drawableTop="@drawable/icon"
android:layout_height="wrap_content"
android:textSize="10dp">
</Button>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我对drawableTop/left/bottom/right属性的理解是正确的,那么不会将您的图像放置在按钮内,而是将其放置在按钮的顶部(北部)。
如果您想将图像放入按钮中,请查看 ImageButton 。
我认为这些东西都不会让你只设置图像的大小(它们会让你改变整个视图的大小,在这种情况下是矩形按钮框,以及其中的图像。
)为了改变图像的大小而不影响按钮框图形的大小我认为你必须在 Photoshop 或其他东西中缩小你的资源图像。
if my understanding of the drawableTop/left/bottom/right properties is correct that is not going to place your image inside your button, rather it is going to put it on top (north of) your button.
If you're looking to put an image inside a button check out ImageButton.
I don't think either of these things will let you just set the size of only your image though (they will let you change the size of the whole view, in this case the rectangle button box, and the image inside it.)
In order to change the size of the image without affecting the size of the button box graphic I think you'd have to shrink your resource image in photoshop or something.