0

The android layout lacks proportion when I set the background of Imagebutton.

enter image description here

And the code of xml is like the following:

<?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:baselineAligned="false"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/player_frame"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/buttonLayout" >

        <FrameLayout
            android:id="@+id/player_surface_frame"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center" >

            <SurfaceView
                android:id="@+id/player_surface"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center" />
        </FrameLayout>
    </FrameLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/findCameraButton"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:text="@string/label_find_camera" />

            <Button
                android:id="@+id/SettingButton"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:text="@string/Camera_WiFi_setup" />

            <ImageButton
                android:id="@+id/FileSavebutton"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:background="@drawable/save_in_camera" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
                <TextView
                android:id="@+id/TimeStampLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dip"
                android:text=""
                android:textColor="#ffff00"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </LinearLayout> 

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/snapshotButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="4"
                android:text="@string/label_app_snapshot" />

            <Button
                android:id="@+id/recordButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="4"
                android:text="@string/label_app_record" />

             <ImageButton
                android:id="@+id/photo_record_mode"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:background="@drawable/turn_to_photomode"/>

        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

How to setup can make the top of LinearLayout no deformation like the LinearLayout of bottom ?

Kanwaljit Singh
  • 4,339
  • 2
  • 18
  • 21
Wun
  • 6,211
  • 11
  • 56
  • 101

2 Answers2

0

Have you tried changing all the android:layout_height values from match_parent to wrap_content?

Gavin
  • 460
  • 4
  • 11
0

i think you should use scaleType to get your image look nice

prefer fitXY

like that android:scaleType="fitXY"

put inside your xml to be whole code like that

 <ImageButton
                android:id="@+id/photo_record_mode"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:background="@drawable/turn_to_photomode"
                android:scaleType="fitXY"/>
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156