android - Layout: background picture streched -


i have difficulties layout.

as first dev project, i'm trying make simple chronometer. want have picture of chronometer in background , start , stop button @ bottom of application, side side , filling width of screen.

here best shot, i'm not satisfied.

all widgets placed ... background streched , buttons seem vertically compressed, text @ bottom bit cropped.

i found if 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 ok, buttons .. widgets placed in center of activity.

how can fix ?

by way if want have buttons side side, did choose better solution ?

thanks ! charles.

... , xml ....

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" 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" >  <linearlayout    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical"    android:layout_weight="2" >  <chronometer     android:id="@+id/chronometer1"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:gravity="center" />  </linearlayout>  <linearlayout     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:layout_weight="1" >      <button         android:id="@+id/button1"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_weight="50"         android:text="start" />       <button         android:id="@+id/button2"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_weight="50"         android:text="stop" /> </linearlayout> 

i tried relativelayout. don't know how have 2 buttons of same size without using padding, don't think it's idea if want app run on different screens.

anyway come this, still have streched image , buttons don't have same size.

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background" tools:context=".chronosv1" >  <chronometer     android:id="@+id/chronometer1"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:gravity="center" />  <button     android:id="@+id/button1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true"     android:text="start" />  <button     android:id="@+id/button2"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true"     android:layout_alignparentright="true"     android:layout_torightof="@id/button1"     android:text="stop" /> 

try relativelayout ;) think easier handle linearlayout. maybe can upload picture how looks , give relativelayout solution ;)


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -