android - imageView with layout_weight attribute and src fail to fit the given Size -
when seek have imageview within linearlayout layout_weight , image, imageview takes on entire space.
lets have layout:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="10"> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/blue"/> <imageview android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="8" android:adjustviewbounds="true" android:scaletype="fitcenter" android:background="@color/red"/> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/green"/> </linearlayout>
the layout (onscreen) looks this:
(not plenty reputation post images, sorry)
////////
blue linearlayout (1/10 of main layout)
////////
red imageview (8/10 of main layout)
////////
green linearlayout (1/10 of main layout)
////////
but if add together image(large one...) imageview:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="10"> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/blue"/> <imageview android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="8" android:adjustviewbounds="true" android:scaletype="fitcenter" android:background="@color/red" android:src="@drawable/splash"/> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/green"/> </linearlayout>
it looks this:
////////
red imageview (10/10 of main layout) - image.....
////////
anyone knows how can create src of imageview fit given space(8/10 of main linearlayout) thanks.
apparently issue android studio preview (before android api level 19)
when deploying device works perfect....
android android-studio android-linearlayout android-imageview android-layout-weight
No comments:
Post a Comment