Question

I have a horizontal image which is more wide than tall. I want the image to fill the display fully heightwise and I do not care if the sides get clipped out as it is the center of the image that is important to be seen.

When the android device gets turned to its side, the user should be able to see much more of the image since its a horizontal picture on a horizontal display.

I've been using fill_parent and match_parent and fill content and testing all of these over and over by exporting them to my phone. It is all drastically different from the virtual device verses my phone.

edit: main idea is to cover the entire display when the device is both held horizontal and vertical

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/honktext"
        android:onClick="amazinghonks"
        android:scaleType="centerCrop"
        android:src="@drawable/big_clown" />

<TextView
    android:id="@+id/toptext"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageButton1"
    android:layout_alignRight="@+id/imageButton1"
    android:layout_alignTop="@+id/imageButton1"
    android:layout_margin="0dp"
    android:gravity="center"
    android:text="@string/toptext"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#33B5E5" 
    android:background="#CC303030"
    />

</RelativeLayout>
Was it helpful?

Solution

Did you tried this?

android:scaleType="centerCrop"

or this?

imageView.setScaleType( ImageView.ScaleType.CENTER_CROP );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top