Search code examples
androidimagebuttonscaling

Android ImageButton image scaling


I have two ImageButtons in a LinearLayout. The Facebook image is 320x113 and the Google+ image is 325x113 (same height). I want both images to display with an equal height (and the wider image will show wider). But for some reason when displaying, the Google+ button is scaling the size larger. Why? Why I ask you!

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_weight="0"
        android:paddingTop="@dimen/padding_large"
        android:paddingLeft="@dimen/padding_large"
        android:paddingRight="@dimen/padding_large"
        android:paddingBottom="@dimen/padding_large">

        <ImageButton android:id="@+id/btnFBShare"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:background="@null"
            android:src="@drawable/fb_share"
            android:contentDescription="Share on Facebook"
            />

        <ImageButton android:id="@+id/btnGPShare"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:background="@null"
            android:src="@drawable/gp_share"
            android:contentDescription="Share on Google+" />

        <!--  
            android:layout_weight="1" -->

    </LinearLayout>

enter image description here


Solution

  • The problem had something to due with Eclipse caching the image files. The cached versions were not the same size. Cleaning the project forced Eclipse to use the newer (same sized files) from disk.