我想在显示屏顶部创建一条水平线的小图像缩略图。它们应该从左排列写(全部向左浮动)。当您单击缩略图时,其较大的版本应显示在此行下方。我决定使用水平线性布局(参见 ID = galleryLayout 的那个)。它应该是 LinearLayout 因为我想稍后在 HorizontalScrollView 中使用它。这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffef3a"
android:orientation="vertical"
tools:context=".Gallery01">
<LinearLayout
android:id="@+id/galleryLayout"
android:orientation="horizontal"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="#ffff3e34">
<ImageView
android:src="@drawable/pic02"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ImageView
android:id="@+id/image1"
android:scaleType="fitXY"
android:layout_width="320dp"
android:layout_height="320dp" />
</LinearLayout>
但问题是图像显示在布局的中心,如您在此处看到的:
如您所见,LinearLayout 中的重力不起作用,图像水平显示在中心。ImageView 本身的重力也不能正常工作(这只是试图让它工作!)。
你们知道我做错了什么吗?谢谢你的帮助!!