android studioでLayout配置が以前よりうまくいかない部分があり、ネット検索で色々調べてみたのですがどうしても回答にたどり着けなかったので質問します。
◎やりたいこと 画像を上部左端と右端に表示したい
2つの画像(header_aとheader_b)を上部の左端にheader_aと右端にheader_bを表示したいのですが
下記の様なコードをlayoutのxmlファイル(activity_main)で記述すると画像が両方とも左に寄ってしまいます。
どうすれば左右に寄せて表示することができるでしょうか?
xml
1コード 2<?xml version="1.0" encoding="utf-8"?> 3<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:orientation="horizontal" 8 tools:context="com.xxxx.testapp.MainActivity"> 9 10 <ImageView 11 android:layout_width="50dp" 12 android:layout_height="50dp" 13 android:layout_gravity="right" 14 android:background="@drawable/header_a"/> 15 <ImageView 16 android:layout_width="50dp" 17 android:layout_height="50dp" 18 android:layout_gravity="left" 19 android:background="@drawable/header_b"/> 20</LinearLayout>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/06/12 08:29