I have an activity containing only one ImageView
. This view should display an image loaded from an URL. I want, that this image will be shown on the top of my screen using the whole screen width.
My layout-file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/overview_bgColor" >
<ImageView
android:id="@+id/overview_image"
android:contentDescription="image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|fill_horizontal"/>
</LinearLayout>
But the image is always shown vertically centered. But why? I thought, that top
will place this ImageView
on top of my screen?
try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/overview_bgColor" >
<ImageView
android:id="@+id/overview_image"
android:contentDescription="image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
/>
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With