The weighting is causing your problem here. You're specifying weightSum="1"
on your LinearLayout
, and then layout_weight="0.5"
on your ImageView
. This means that the image will only ever take up half the available space - the first half, for the layout you've got here. If you had set weightSum="2"
and your image to layout_weight="0.5"
, your image would only take up one quarter of the space (since the assigned weight is 1/4 of the total).
You can fix this by either removing the weightSum
and layout_weight
attributes, or removing the LinearLayout
altogether. I'd recommend removing the LinearLayout
as there's no other children and it's not necessary;
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/logo"
android:scaleType="centerInside" />
I misunderstood. This works for me:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.25" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="@drawable/logo" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.25" />
</LinearLayout>