2017-06-13 9 views
1

2つのイメージを線形レイアウトで右側に整列したいと思います.2つのイメージ間にスペースを追加するにはどうすればいいですか? ここに私のコードです。2つのイメージを線形レイアウトで整列します

Vechile.xml

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 
    <Image 
    android:id="@+id/image1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/img1" 
    android:layout_marginEnd="20dp" /> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <View 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:layout_weight="1" />     

    <Image 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginEnd="10dp" 
    android:src="@drawable/img2" 
    android:id="@+id/image2"/> 

</LinearLayout> 
</LinearLayout> 

答えて

0

右あなたのLinearLayoutの重力を設定し、このようなあなたのImageViewsにいくらかのマージンを取る:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:gravity="right"> 

<ImageView 
    android:id="@+id/image1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="5dp" 
    android:background="@drawable/arrow_down_black_24dp" 
    /> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/image2" 
    android:layout_margin="5dp" 
    android:background="@drawable/arrow_down_black_24dp" 
    /> 

</LinearLayout> 
関連する問題