0

I have got two LinearLayouts. I the first LinearLayout I set ImageButton. How fill imagebutton edges equally with the LinearLayout and next how fill background image edges equally with ImageButton??

For example. If my LinearLayout have dimension height:20 dp width:20dp, then imagebutton should have dimension dimension height:20 dp width:20dp and background image should have dimension dimension height:20 dp width:20dp.

My code:

    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:showDividers="none" >

    <LinearLayout
        android:id="@+id/zdj"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_weight="0.25"
        android:orientation="vertical"

        >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:scaleType="fitCenter"
            android:src="@drawable/wawel" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_weight="0.75"
        android:background="@drawable/tlo12"
        android:orientation="horizontal"
        android:paddingLeft="@dimen/activity_horizontal_margin">

    <TextView
        android:id="@+id/textViewNazwaObiektu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1.63"
        android:textSize="20sp" />

    </LinearLayout>


</TableRow>
Bhavin Nattar
  • 3,189
  • 2
  • 22
  • 30

1 Answers1

0

If you use

        android:scaleType="fitCenter"

your image won't fill up the whole imageview

If you don't care about the image aspects use:

        android:scaleType="fitXY"
Ion Aalbers
  • 7,830
  • 3
  • 37
  • 50
  • It's worth pointing out that ImageView has a default scaleType of fitCenter, while Button's default is fitXY. Not sure for ImageButton, though. – npace Jul 12 '13 at 10:05
  • I have changed android:scaleType="fitCenter" to android:scaleType="fitXY" but still is the same;/ – user2409613 Jul 12 '13 at 11:24
  • try setting the background of the ImageButton to null "android:background="@null" This wil remove the button background, this background contains padding within its image. – Ion Aalbers Jul 12 '13 at 11:38