Skip to content Skip to sidebar Skip to footer

Fitting Three Buttons And A Background Image In Android

I am trying to develop an Android app that should look like an iOS I have done last month. There is a view with a background image and three buttons. The background image has a hea

Solution 1:

I think using Linear Layout with weight will solve your problem. Try this.

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"android:weightSum="3"android:background="@drawable/ic_action_search"><Buttonandroid:id="@+id/button1"android:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"android:drawableLeft="@drawable/ic_launcher"android:text="Agenda" /><Buttonandroid:id="@+id/button2"android:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"android:drawableLeft="@drawable/ic_action_search"android:text="Actividades" /><Buttonandroid:id="@+id/button3"android:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"android:drawableLeft="@drawable/fail"android:text="Recibir Información de Juventud" /></LinearLayout>

Solution 2:

try this and let me know the result.

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"android:background="@drawable/fondo_pantalla"> >
   <Buttonandroid:id="@+id/button2"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_below="@+id/button1"android:drawableLeft="@drawable/actividades_izq"android:text="Actividades"layout_weight="1" /><Buttonandroid:id="@+id/button1"android:layout_width="fill_parent"android:layout_height="fill_parent"android:drawableLeft="@drawable/agenda_izq"android:paddingTop="60dp"android:text="Agenda"layout_weight="1"/><Buttonandroid:id="@+id/button3"android:layout_width="fill_parent"android:layout_height="fill_parent"android:drawableLeft="@drawable/suscribete_izq"android:text="Recibir Información de Juventud"layout_weight="1"/></LinearLayout>

Solution 3:

I think your problem is trying to provide on layout for all screensizes and densities. This will hardly be possible. But what you can do is create seperate folders in your res-folder

layout-small
layout-medium
layout-large

And so on. Please read this article carefully because in your preview you are supporting nearly every screensize and density with just one layout...

Put your custom layouts into the seperate layout-folders to give the users the experience they want. Hope it helps ;)

Solution 4:

Start by putting button2 to :

android:layout_centerInParent="true"

and button1 to :

android:above="@+id\button2"

That way at least its centered and can adjust better to screen sizes.

Post a Comment for "Fitting Three Buttons And A Background Image In Android"