I have a problem with Glide when i try to load in a ImageView parallax.
My picture is 1920x1080 (example: http://www.buildingagamingpcsite.com/wp-content/uploads/2016/07/Crysis3_Screenshot_TheHunter.jpg) and i try to load in a Image View with height in dp:
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="320dp"
android:nestedScrollingEnabled="false"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways" />
I want the image take all container, but the result is that: ImageView
What is the code of glide to take this?
My code is inside a collapsingToolbarLayout:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<!-- Collapser -->
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapser"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!-- Image del detalle -->
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="320dp"
android:nestedScrollingEnabled="false"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
You should add the android:scaleType
attribute to your ImageView.
If you want to display the pictures in proportion, you can use centerCrop
.
If you don't want to display the pictures in proportion, you can use fitXY
.
You can use this.
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<!-- Collapser -->
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapser"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!-- Image del detalle -->
<ImageView
android:id="@+id/image"
android:src="@mipmap/bg_user"
android:layout_width="match_parent"
android:layout_height="320dp"
android:nestedScrollingEnabled="false"
android:scaleType="fitXY"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>