在我的水平LinearLayout中,我有一个TextEdit和一个
ImageButton.
ImageButton与TextEdit一样高.
我希望ImageButton的长度和它一样宽.
目前看起来ImageButton的宽度就像没有缩放时一样(ImageButton width [px] =未缩放的可绘制宽度[px]):
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <EditText android:id="@+id/txtName" android:layout_width="1dp" android:layout_height="wrap_content" android:layout_weight="1" /> <ImageButton android:id="@+id/btSet" android:layout_width="wrap_content" android:layout_height="match_parent" android:scaleType="fitEnd" android:src="@drawable/pin2" /> </LinearLayout>
它应该如何:
解决方法
试试这个,我认为这应该有效:
<RelativeLayout android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal" > <ImageButton android:id="@+id/btSet" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentRight="true" android:scaleType="centerInside" android:adjustViewBounds="true" android:src="@drawable/pin2" /> <EditText android:id="@+id/txtName" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_toLeftOf="@id/btSet" /> </RelativeLayout>
解释:centerInside将确保图像在ImageButton的范围内按比例缩放. adjustViewBounds =“true”将…好吧,调整视图的边界,如果图像需要缩放.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。