ImageButton の大きさを親 View にフィットさせたい
DialogFragment で表示する View に ImageButton を平行に2つ並べています。
AndroidStudio 上では大きくなっているのですが、実機で表示すると大きくならない症状が発生しており、それを解決する方法を探しています。
ImageButton は、LinearLayout(Horizontal) 内に並べてあり、2つのボタンの layout_weight は 1 です。
画像は src に定義してあり、scaleType は fitCenter です。
background は #00000000(透明) です。
実機で表示すると、レイアウトとしては水平方向は均等割で表示しているのですが、ImageButton 自体のサイズが原寸のままで表示されているようです。
ImageButton の画像はアスペクト比を保ったまま大きくしたいです。
解決方法をご存知の方は教えていただけると助かります。
解決に必要な情報がございましたら、お申し付けください。
よろしくお願いします。
layout.xml
xml
1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:orientation="vertical"> 7 8 <FrameLayout 9 android:layout_width="match_parent" 10 android:layout_height="wrap_content" 11 android:layout_gravity="center_horizontal"> 12 13 <LinearLayout 14 android:layout_width="match_parent" 15 android:layout_height="wrap_content" 16 android:layout_gravity="center" 17 android:layout_marginBottom="10dp" 18 android:layout_marginEnd="8dp" 19 android:layout_marginStart="8dp" 20 android:layout_marginTop="10dp" 21 android:background="@drawable/background_orange" 22 android:gravity="center_horizontal" 23 android:orientation="vertical"> 24 25 <ImageView 26 android:id="@+id/image_title" 27 android:layout_width="match_parent" 28 android:layout_height="wrap_content" 29 android:adjustViewBounds="true" 30 android:scaleType="fitCenter" 31 app:srcCompat="@mipmap/image_title" /> 32 33 <TextView 34 android:id="@+id/text_comment" 35 android:layout_width="match_parent" 36 android:layout_height="match_parent" 37 android:background="@null" 38 android:text="あああああいいいいいうううううえええええおおおおおあああああいいいいいうううううえええええおおおおおあああああいいいいいうううううえええええおおおおおあああああいいいいいうううううえええええおおおおおあああああいいいいいうううううえええええおおおおお" /> 39 40 <LinearLayout 41 android:layout_width="match_parent" 42 android:layout_height="match_parent" 43 android:orientation="horizontal"> 44 45 <ImageButton 46 android:id="@+id/button1" 47 android:layout_width="0dp" 48 android:layout_height="match_parent" 49 android:layout_weight="1" 50 android:adjustViewBounds="true" 51 android:background="#00000000" 52 android:scaleType="fitCenter" 53 android:src="@mipmap/button1" /> 54 55 <ImageButton 56 android:id="@+id/button2" 57 android:layout_width="0dp" 58 android:layout_height="match_parent" 59 android:layout_weight="1" 60 android:adjustViewBounds="true" 61 android:background="#00000000" 62 android:scaleType="fitCenter" 63 android:src="@mipmap/button2" /> 64 </LinearLayout> 65 66 </LinearLayout> 67 68 <ImageButton 69 android:id="@+id/dialog_close_button" 70 android:layout_width="30dp" 71 android:layout_height="30dp" 72 android:layout_gravity="top|end" 73 android:adjustViewBounds="true" 74 android:background="#00000000" 75 android:scaleType="fitCenter" 76 android:visibility="gone" 77 app:srcCompat="@mipmap/dialog_close_button" /> 78 79 </FrameLayout> 80 81</LinearLayout>
補足情報(FW/ツールのバージョンなど)
AndroidStudio3.1.2
説明画像
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/06 05:58