1

I have a problem sizing a picture into a imagebutton. Actually my button holds a image that is too large and I can see only a part of my picture on the imagebutton.

I have a activity with a layout which defines a webview with a button at the bottom in a sizerelation of 1/8. I mean the webview takes 8 parts of the screen and the button 1 part. My layout looks simplified like this :

WebView
  ...
  ...
  android:layout_weight="8" /
LinearLayout
  ...
  ...
  android:layout_weight="1"
  <ImageButton
  ...
  android:layout_weight="1"/
/LinearLayout

because of the weight definitions, I do not know the pixelsize of my button and I can't size my picture into the button correctly.

How can I size my image to the button correctly ? Or how can I manager that my button is sized correctly into my button ?

mcfly soft
  • 11,289
  • 26
  • 98
  • 202

1 Answers1

0

Hopefully you are get help from below my codes. such as

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="#000"
            android:layout_weight="7" />

        <Button
            android:id="@+id/bLogin"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="#ff0000"
            android:layout_weight="1" />
    </LinearLayout>

</LinearLayout>

Now you can modify dependable on you wish. Best of luck!