如何并排排列不均匀尺寸的图像?

时间:2018-05-14 10:24:01

标签: android android-layout imageview

我想并排显示多个不均匀尺寸的图像。基本上我想要这样的结构。 :

Check Here

这是我的代码,但它自上而下:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        android:layout_weight="4">



        <ImageView
            android:id="@+id/offerBanner1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:src="@drawable/ic_offer_banner1"
            android:scaleType="fitCenter" />

        <ImageView
            android:id="@+id/offerBanner2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:src="@drawable/ic_offer_banner2"
            android:scaleType="fitCenter" />


    </LinearLayout>

任何形式的帮助都将受到高度赞赏。 感谢

1 个答案:

答案 0 :(得分:0)

尝试这样并排获取图像

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"> <!--horizontal here-->

    <ImageView
        android:id="@+id/offerBanner1"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/ic_offer_banner1"
        android:scaleType="fitCenter" />

    <ImageView
        android:id="@+id/offerBanner2"
         android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/ic_offer_banner2"
        android:scaleType="fitCenter" />

</LinearLayout>