1

LinearLayoutに2つ並べて使用しています。ImageViewに画像を配置しましたImageView。次に、上の画像の上に小さな画像を追加する必要がありますImageViewRelativelayout私は多くの投稿を見てきましたが、それらはすべてorを扱っていFramelayoutます。以下は、私が使用した XML コード セグメントです。

<LinearLayout
    android:id="@+id/relativeLayout2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dip"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imgmode31"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:adjustViewBounds="true"
        android:maxHeight="180dp"
        android:maxWidth="140dp"
        android:scaleType="fitXY"
        android:src="@drawable/i5" >
    </ImageView>

    <ImageView
        android:id="@+id/imgmode32"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:longClickable="false"
        android:maxHeight="180dp"
        android:maxWidth="280dp"
        android:scaleType="fitXY"
        android:src="@drawable/i1" >
    </ImageView>

</LinearLayout>

どんな助けでも大歓迎です。

4

3 に答える 3

1

これはまさに線形レイアウトが防止するはずのものです。ただし、負のパディングを使用して次の要素の配置をオーバーライドできる場合があります。それに関する問題は、さまざまな画面密度で何が起こるかです。

これが表面ビューの意味だと思います。画面全体に透明な描画面を提供し、他のビューの上に描画できるようにします。

最後のアイデアは、最初の画像を線形レイアウト内のフレーム レイアウトに配置することです。次に、パディングを使用して重ね合わせた画像をフレーム レイアウトに追加して配置できます。

于 2012-06-08T17:33:14.737 に答える
1

相対レイアウトで簡単に実行できます

<RelativeLayout 
android:id="@+id/relativeLayout2" 
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
    <ImageView     
     android:layout_height="wrap_content"     
     android:layout_width="wrap_content"   
     android:adjustViewBounds="true" 
     android:scaleType="fitXY"
     android:src="@drawable/i5"
     android:id="@+id/imgmode31" 
     android:maxHeight="180dp" 
     android:maxWidth="140dp">
   </ImageView>
   <ImageView     
     android:layout_height="wrap_content"     
     android:layout_width="wrap_content"  
     android:scaleType="fitXY" 
     android:longClickable="false"  
     android:adjustViewBounds="true" 
     android:src="@drawable/i1" 
     android:id="@+id/imgmode32" 
     android:maxHeight="180dp" 
     android:maxWidth="280dp">
   </ImageView>
</RelativeLayout>

ImagView互いにオーバーラップさせたい場合は、それらHeightWidth同じにImageViewします。実行時にいずれかを前面に出すこともできます

于 2012-06-08T17:35:40.213 に答える
0

ALinearLayoutは要素を直線的に並べて配置します。FrameLayout要素を別の要素の上に配置する場合は、またはに頼る必要がありますRelativeLayout

をa に変更するLinearLayoutと、2 つの が重なっているのFrameLayoutがわかります。ImageView

于 2012-06-08T17:29:05.893 に答える