修复 Android 中 Imageview 的大小
我有一个 LinearLayout,其中一列中有六个水平按钮的列表。
每个都有这样的结构:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_menu_charge" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_top_up_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fontFamily="@font/montserrat_bold"
android:gravity="center_vertical"
android:text="@string/menu_pay_charge"
android:textColor="@color/black"
app:drawableEndCompat="@drawable/ic_arrow_right_small_black" />
</LinearLayout>
问题是每个列表元素都有自己的大小,我无法获得完美的列
如何为每个ImageView
设置固定大小(而不增加可绘制大小) ?
I have a LinearLayout
with a list of six horizontal buttons in a column.
Each one has this structure:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_menu_charge" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_top_up_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fontFamily="@font/montserrat_bold"
android:gravity="center_vertical"
android:text="@string/menu_pay_charge"
android:textColor="@color/black"
app:drawableEndCompat="@drawable/ic_arrow_right_small_black" />
</LinearLayout>
The problem is that each list element has its own size and I can't get a perfect column
How can I set a fixed size for each ImageView
(without increasing the drawable size)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要给出
imageView
固定宽度,例如:或者,您可以使用
layout_weight
,例如:You need to give the
ImageView
a fixed width, e.g. :Or, you can use
layout_weight
, e.g. :打开图像并更改为相同的大小,然后将它们添加到可绘制对象中再次
尝试
open the imagens and change to the same size, then add them to the drawable again
try that