android - LinearLayout 项目不会改变重力
问题描述
我有以下布局:
<LinearLayout
orientation="horizontal"
layout_width="match_parent"
layout_height="match_parent">
<ImageView
layout_width="50dp"
layout_height="match_parent"
srcCompat="@drawable/eshop"
id="@+id/imageView"
contentDescription="@string/eshop_icon_description"/>
<TextView
id="@+id/game_price"
text="@string/game_price"
layout_margin="5dp"
layout_width="wrap_content"
layout_height="wrap_content"
textColor="#2196F3"/>
<TextView
id="@+id/game_discount"
text="@string/game_discount"
layout_marginTop="5dp"
layout_marginEnd="5dp"
layout_marginRight="5dp"
layout_width="wrap_content"
layout_height="wrap_content"
textColor="#E91E63"/>
</LinearLayout>
这是它的外观:
我希望价格和折扣位于右侧,徽标位于左侧,但它们不会使用重力布局或重力改变。
我错过了什么?
解决方案
让你LinearLayout
定位vertical
而不是horizontal
然后使用android:layout_gravity="left"
或android:layout_gravity="right"
推荐阅读
- python - 使用 Python 在 S3 中将 CSV 转换为 Parquet
- angular - 将 URL 值从父级传递给子级
- reactjs - React + fetch:在我的网址中添加额外的字符和反斜杠
- android - Xamarin 生成问题说明 Zza 类型是在未引用的程序集中定义的。找不到 Xamarin.GooglePlayServices.Basement
- google-apps-script - 此代码应该将数据从我的电子表格转换为文档,然后转换为 pdf,但它只执行最后一行
- arrays - 谷歌表格根据按变量排序的不同变量对两列求和
- php - 创建没有双值的多维数组
- python - DataFrame 返回不正确的值 Pandas
- bcrypt - 安装 passlib [bcrypt] 时无法安装 6-1.16.0
- python - 带有 URL 的 aiohttp unittest 不是 GET