Thursday, April 18, 2013

[android help] Layout: background picture streched


I have difficulties with my layout.


As my first dev project, I'm trying to make a simple chronometer. I want to have a picture of a chronometer in the background and the start and stop button at the bottom of the application, side by side and filling the width of the screen.


Here is my best shot, but I'm not satisfied.


All widgets are placed properly but ... My background is streched and my buttons seem vertically compressed, even the text at the bottom is a bit cropped.


I found that if I change these lines



android:layout_width="fill_parent"
android:layout_height="fill_parent"


by



android:layout_width="wrap_content"
android:layout_height="wrap_content"


The background is ok, the buttons too .. but all widgets are placed in the center of the Activity.


How can I fix this ?


By the way if I want to have my buttons side by side, did I choose the better solution ?


Thanks for your help ! Charles.


... and now my xml ....



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background"
tools:context=".Chronosv1" >

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2" >

android:id="@+id/chronometer1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" />



android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >

android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:text="START" />

android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:text="STOP" />



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...