Button with responsive image

0

I have several buttons that reset depending on the size of the device, however, the images inserted in it do not adjust automatically, and always end up with a fixed size. How can I make these images responsive?

<ImageView
    android:id="@+id/imagem2"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:layout_gravity="center"
    android:background="#9b1136"
    android:src="@drawable/logove2" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/botaoEmpresa"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" 
        android:drawableTop="@drawable/empresas"
        android:text="Empresas"
        />

    <Button
         android:id="@+id/botaoContato"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" 
        android:drawableTop="@drawable/contato"
        android:text="Contato"

        />

    <Button
        android:id="@+id/botaoRede"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" 
         android:drawableTop="@drawable/redes"
         android:text="Redes Sociais"
        />

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <Button
        android:layout_width="0dp"
        android:layout_height="match_parent"
       android:drawableTop="@drawable/servicosuteis"
       android:text="Serviço uteis"
        android:layout_weight="1" />

   <Button
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:drawableTop="@drawable/desconto"
        android:text="Mult  Desconto"
        android:layout_weight="1" />
   <Button
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:drawableTop="@drawable/revista"
        android:text="Revista"
        android:layout_weight="1" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"

    android:orientation="horizontal" >

    <Button
        android:id="@+id/botaoRegiao"
        android:layout_width="0dp"
        android:layout_height="match_parent"

       android:drawableTop="@drawable/mapa2"
       android:text="Altere sua região"
        android:layout_weight="1" />


</LinearLayout>

I wanted the images inside it to readjust, how can I solve this problem?

    
asked by anonymous 10.12.2014 / 20:29

1 answer

0

Wrap each LinearLayout in a FrameLayout.

A classic example:

<? 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">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:orientation="vertical">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.25">
            <LinearLayout
                android:id="@+id/linear1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="horizontal">
                <ImageButton
                    android:id="@+id/imageButton2"
                    android:layout_width="0dp"
                    android:layout_weight="0.40"
                    android:layout_height="fill_parent"
                    android:src="@drawable/ic_pages" />
                <ImageButton
                    android:id="@+id/imageButton1"
                    android:layout_width="0dp"
                    android:layout_weight="0.60"
                    android:layout_height="fill_parent"
                    android:src="@drawable/ic_pages" />
            </ LinearLayout>
        </ FrameLayout>
    </ LinearLayout>
</ RelativeLayout>
    
10.12.2014 / 21:24