2011-10-20 10 views
0

ライナーレイアウト/相対レイアウト内に画像を配置したいAndroid:画像サイズの定義

2つの画像を連続して保存したい。 これらの画像の幅を定義すると、両方とも一緒に親を水平に塗りつぶすようになります。

イメージ間の必要な間隔にlayout_marginを使用できます。しかし、私はそれが親を埋めるように幅を定義することができません。

私は別のディップで裁判を行う必要がありますが、水平

+0

利用アンドロイド:layout_weight、この記事を参照してください。http://stackoverflow.com/questions/3995825/what-is-androidlayout-weight-meaning – Houcine

答えて

0

試してみると2 ImageViewsを入れあなたのxmlでこのように

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:weightSum="2"> 
    <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1" 
     android:src="@drawable/icon" android:layout_width="0dp" 
     android:layout_weight="1" android:scaleType="fitXY"></ImageView> 
    <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1" 
     android:src="@drawable/icon" android:layout_width="0dp" android:scaleType="fitXY" 
     android:layout_weight="1"></ImageView> 
</LinearLayout> 
+0

あなたはhttp://stackoverflow.com/をご覧ください。質問/ 7834737/android-row-spanning-for-images/7834816#7834816とmy xmlを修正してください。 – png

+0

私が与えた確かなチェック – MKJParekh

0

セットLinearLayoutのオリエンテーション値プロパティ

android:layout_width = "fill_parent" 
android:layout_height = "wrap_content" 
android:layout_weight = "1" 
+0

実は、この質問は私の部分的な要件でした。実際の質問はhttp://stackoverflow.com/questions/7834737/android-row-spanning-for-images/7834816#7834816 – png

+0

です。私は答えを得ていないので、私は問題によって攻撃を試みていました。あなたが私の問題のための解決策を持っているなら、それは素晴らしいことでしょう。私は重量を割り当てることによってトライをしていますが、それは動作しません。 – png

1

使用

android:layout_weight="1" for parent 
and android:layout_weight="0.5" for childs 
+0

+1すてきな答え..イメージの高さの幅を与える方法を置く方がいいでしょう。 – MKJParekh

関連する問題