在LinearLayout中对齐两个图像和文本

时间:2016-05-17 18:12:38

标签: android android-layout

我想对齐两张图片和文字。当第一张图片被注释掉时,文本和第二张图片在卡片的中间对齐。但第一张图片始终与卡片的底部对齐。到目前为止,我尝试了所有布局属性而没有运气。

请参阅屏幕截图。我不明白为什么圆圈大于OK按钮,因为当我打开这些文件时,它们具有相同的尺寸。问题在哪里?我想使用<android.support.v7.widget.CardView android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginRight="8dp" android:layout_marginLeft="8dp" android:layout_marginBottom="4dp" android:layout_marginTop="4dp" app:cardCornerRadius="4dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="16dp" android:layout_marginTop="14dp" android:orientation="horizontal"> <ImageView android:id="@+id/badge_type" android:src="@drawable/ic_gold_circle" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/badge_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="10dp" android:layout_marginLeft="10dp" android:text="@string/badge_title_KNIGHT" style="@style/PlayRecordHeader" /> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" /> <ImageView android:id="@+id/badge_status" android:src="@drawable/ic_correct" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dp"/> </LinearLayout> </android.support.v7.widget.CardView> 作为最简单的布局管理器。

Teacher Licensure Info

layout_gravity="center_vertical"
使用data[select]

更新

enter image description here

1 个答案:

答案 0 :(得分:0)

我认为你必须保持

android:layout_gravity="center_vertical"

并删除

android:layout_marginLeft="16dp"
android:layout_marginTop="14dp"
LinearLayout

中的