gpt4 book ai didi

android - 如何在 ImageButton 中对齐图像源?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:49:20 25 4
gpt4 key购买 nike

我有一个图像按钮,我想把它带到设备的整个宽度。我使用的图像 src 没有按钮那么长。默认似乎是将其与按钮的中心对齐。相反,我想将它向左对齐。我尝试过使用布局引力但没有任何反应。

这是代码..

<LinearLayout 
android:id = "@+id/llRoot"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left" >

<ImageButton
android:id="@+id/ibSend"
android:layout_gravity="left"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/send" >
</ImageButton>

最佳答案

嗯,我想你想让 ImageButton 中的图像左对齐?然后将其添加到您的 ImageButton 属性中:

android:scaleType="fitStart"

现在,您的图像在 ImageButton 的左侧对齐。

关于android - 如何在 ImageButton 中对齐图像源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6688307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com