PlayGround Article 開発, ブログ Kotlinはじめました day03 mcz9mm 2019年1月4日 Created with Sketch. 0 Created with Sketch. 429 ## やったこと - viewを比率で配置 - ImageViewの表示方法を変更する ## viewを比率で配置 レイアウトの重み付けを利用して表示してみる。  ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="5"> <View android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="1" android:background="#2ecc71"/> <View android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="3" android:background="#3498db"/> <View android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="1" android:background="#2ecc71"/> </LinearLayout> ``` ## ImageViewの表示方法を変更する https://developer.android.com/reference/android/widget/ImageView.ScaleType - CENTER Viewの中央に表示、拡大縮小無し - CENTER_CROP View内で画像の縦横比を維持し、Cropして中央に配置 - CENTER_INSIDE View内で画像の縦横比を維持し画像すべてをView内の中央に配置 - FIT_CENTER View内で画像の縦横比を維持し中央に配置 - FIT_END View内で画像の縦横比を維持し、右下に寄せて配置 - FIT_START View内で画像の縦横比を維持し、左上に寄せて配置 - FIT_XY View内で縦横を独立してリサイズし、フル画面にする - MATRIX Image Matrix を使うときに使用する