観覧ありがとうございます。
いつもお世話になっています。
早速本題なのですが
Androidの画面にCardViewをおいてその中にLinearLayoutを横に2つ並べて同じ幅のサイズにした後
片方のLinearLayoutの中にあるImageViewの中に大きい画像を入れるとLinearLayoutの幅が変わってしまいます。
ImageViewのscaleTypeを変えてみたりしたのですが結局LineaLayoutの幅が変わってしまいます。
LinearLayoutのサイズを変えないまま画像を入れたいのですがどうしたら良いでしょうか?
お願いします。
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/tools" 4 android:id="@+id/layout" 5 android:layout_width="match_parent" 6 android:layout_height="wrap_content" 7 android:orientation="vertical" 8 android:paddingBottom="15dp" 9 android:paddingLeft="15dp" 10 android:paddingRight="15dp"> 11 12 <android.support.v7.widget.CardView 13 android:id="@+id/cardView" 14 android:layout_width="match_parent" 15 android:layout_height="wrap_content" 16 app:cardUseCompatPadding="true" 17 app:cardCornerRadius="10dp"> 18 19 <LinearLayout 20 android:id="@+id/cardLayout" 21 android:layout_width="match_parent" 22 android:layout_height="match_parent" 23 android:layout_gravity="center_horizontal" 24 android:orientation="horizontal"> 25 26 <LinearLayout 27 android:layout_width="wrap_content" 28 android:layout_height="match_parent" 29 android:layout_weight="1" 30 android:orientation="horizontal"> 31 32 <ImageView 33 android:id="@+id/goodsImageView" 34 android:layout_width="wrap_content" 35 android:layout_height="wrap_content" 36 android:adjustViewBounds="true" 37 android:scaleType="center"/> 38 39 40 </LinearLayout> 41 42 43 <LinearLayout 44 android:layout_width="wrap_content" 45 android:layout_height="match_parent" 46 android:layout_weight="1" 47 android:orientation="vertical" 48 android:background="@color/colorPrimary"> 49 50 <TextView 51 android:id="@+id/goodsTextView" 52 android:layout_width="match_parent" 53 android:layout_height="wrap_content" 54 android:textAlignment="center" 55 android:textSize="30sp"/> 56 57 <TextView 58 android:id="@+id/genresTextView" 59 android:layout_width="match_parent" 60 android:layout_height="wrap_content" 61 android:textAlignment="center" 62 android:textSize="15sp" 63 android:text="test"/> 64 65 </LinearLayout> 66 67 68 69 70 </LinearLayout> 71 </android.support.v7.widget.CardView> 72</LinearLayout>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/24 06:37