初心者のため、至らないところもあるかと思いますがお願いいたします。
現在、AndroiStudioでアプリを作成中です。
そこで、現在Layoutの、xmlファイルで画像のような表示になっています。
そこでLAYOUTRIGHTボタンをImageViewにかえたいのですが、ボタン部分を置き換えると
画像が表示されません。
これはなぜでしょうか?また、表示させるにはどのようにすればよいのでしょうか?
お分かりの方、ぜひご教授いただけますようお願いいたします。
変更前:
xml
1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:orientation="vertical" 6 android:paddingBottom="4dp" 7 android:paddingLeft="4dp" 8 android:paddingRight="4dp" 9 android:paddingTop="4dp"> 10 11 <RelativeLayout 12 android:layout_width="fill_parent" 13 android:layout_height="100dp" 14 android:weightSum="1"> 15 <LinearLayout 16 android:id="@+id/LayoutRight" 17 android:layout_width="wrap_content" 18 android:layout_height="100dp" 19 android:layout_alignParentLeft="true" 20 android:layout_above="@+id/LayoutDumy"> 21 <Button 22 android:layout_width="wrap_content" 23 android:layout_height="100dp" 24 android:text="LayoutRight"></Button> 25 </LinearLayout> 26 27 <LinearLayout 28 android:id="@+id/LayoutLeft" 29 android:layout_width="fill_parent" 30 android:layout_height="match_parent" 31 android:layout_toRightOf="@+id/LayoutRight" 32 android:orientation="vertical"> 33 <!-- 店名 --> 34 <TextView 35 android:id="@+id/text05ShopNm" 36 android:layout_width="wrap_content" 37 android:layout_height="wrap_content" 38 android:textColor="#000000" 39 android:textSize="20sp" /> 40 41 <LinearLayout 42 android:layout_width="match_parent" 43 android:layout_height="wrap_content" 44 android:orientation="horizontal" 45 android:weightSum="1"> 46 47 <!-- タイトル:コメント --> 48 <TextView 49 android:id="@+id/text05TitleComment" 50 android:layout_width="0dp" 51 android:layout_height="match_parent" 52 android:layout_weight="0.2" 53 android:text="@string/text05_title_Comment" 54 android:textSize="10sp" /> 55 56 <!-- データ表示用:コメント --> 57 <TextView 58 android:id="@+id/text05Comment" 59 android:layout_width="match_parent" 60 android:layout_height="65dp" 61 android:layout_weight="0.8" 62 android:textColor="#000000" 63 android:textSize="10sp" /> 64 </LinearLayout> 65 </LinearLayout> 66 67 <LinearLayout 68 android:id="@+id/LayoutDumy" 69 android:layout_width="0dp" 70 android:layout_height="wrap_content" 71 android:layout_below="@+id/LayoutLeft" 72 android:orientation="horizontal"> 73 </LinearLayout> 74 </RelativeLayout> 75</LinearLayout>
変更後:
xml
1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:orientation="vertical" 6 android:paddingBottom="4dp" 7 android:paddingLeft="4dp" 8 android:paddingRight="4dp" 9 android:paddingTop="4dp"> 10 11 <RelativeLayout 12 android:layout_width="fill_parent" 13 android:layout_height="100dp" 14 android:weightSum="1"> 15 <LinearLayout 16 android:id="@+id/LayoutRight" 17 android:layout_width="wrap_content" 18 android:layout_height="100dp" 19 android:layout_alignParentLeft="true" 20 android:layout_above="@+id/LayoutDumy"> 21 22 <ImageView 23 android:id="@+id/image_view" 24 android:layout_width="wrap_content" 25 android:layout_height="100dp" 26 android:contentDescription="@string/description" 27 android:scaleType="fitCenter" /> 28 29 </LinearLayout> 30 31 <LinearLayout 32 android:id="@+id/LayoutLeft" 33 android:layout_width="fill_parent" 34 android:layout_height="match_parent" 35 android:layout_toRightOf="@+id/LayoutRight" 36 android:orientation="vertical"> 37 <!-- 店名 --> 38 <TextView 39 android:id="@+id/text05ShopNm" 40 android:layout_width="wrap_content" 41 android:layout_height="wrap_content" 42 android:textColor="#000000" 43 android:textSize="20sp" /> 44 45 <LinearLayout 46 android:layout_width="match_parent" 47 android:layout_height="wrap_content" 48 android:orientation="horizontal" 49 android:weightSum="1"> 50 51 <!-- タイトル:コメント --> 52 <TextView 53 android:id="@+id/text05TitleComment" 54 android:layout_width="0dp" 55 android:layout_height="match_parent" 56 android:layout_weight="0.2" 57 android:text="@string/text05_title_Comment" 58 android:textSize="10sp" /> 59 60 <!-- データ表示用:コメント --> 61 <TextView 62 android:id="@+id/text05Comment" 63 android:layout_width="match_parent" 64 android:layout_height="65dp" 65 android:layout_weight="0.8" 66 android:textColor="#000000" 67 android:textSize="10sp" /> 68 </LinearLayout> 69 </LinearLayout> 70 71 <LinearLayout 72 android:id="@+id/LayoutDumy" 73 android:layout_width="0dp" 74 android:layout_height="wrap_content" 75 android:layout_below="@+id/LayoutLeft" 76 android:orientation="horizontal"> 77 </LinearLayout> 78 </RelativeLayout> 79</LinearLayout>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/08 12:35