(Android Studio) App Background Image Doesn't Fill Screen -


i'm new app programming , require assistance. building simple app on android studio, app's background image (i named "green_background") doesn't entirely fill screen. can't provide screenshot because don't have 10 reputation on stack overflow.

here app's activity coding. have added 1 piece of text, 2 buttons, 2 chronometers , 1 image view:

<imageview     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:id="@+id/imageview"     android:layout_alignright="@+id/button2"     android:layout_alignend="@+id/button2"     android:contentdescription="@string/background_1"     android:layout_alignparentend="@+id/button"     android:layout_alignparentright="@+id/button"     android:background="@drawable/green_background"     android:layout_alignparenttop="true"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true" />    <textview     android:text="@string/revision"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textsize="60sp"     android:id="@+id/textview"     android:layout_alignparenttop="true"     android:layout_centerhorizontal="true" />  <button     android:layout_width="150dp"     android:layout_height="80dp"     android:text="@string/button_work"     android:id="@+id/button"     android:textsize="30sp"     android:clickable="true"     android:textcolor="#ffe7e7e7"     android:background="#d1131110"     android:layout_aligntop="@+id/button2"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true" />  <button     android:layout_width="150dp"     android:layout_height="80dp"     android:text="@string/button_break"     android:id="@+id/button2"     android:textsize="30sp"     android:clickable="true"     android:textcolor="#ffe7e7e7"     android:background="#d1131110"     android:layout_below="@+id/textview"     android:layout_alignparentright="true"     android:layout_alignparentend="true"     android:layout_margintop="59dp" />  <chronometer     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/chronometer"     android:textsize="50sp"     android:layout_below="@+id/button"     android:layout_alignleft="@+id/button"     android:layout_alignstart="@+id/button"     android:layout_margintop="180dp" />  <chronometer     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/chronometer2"     android:textsize="50sp"     android:layout_aligntop="@+id/chronometer"     android:layout_alignparentright="true"     android:layout_alignparentend="true" /> 

how make background image (green_background) fill phone screen?

i think it's happening because of padding present in top level container..that relative layout in case if relative layout looks below code

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity" >

or thing similar that, remove these 4 lines of code

android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" 

which applies padding layout background not visible.

if use of image view show background..here simpler , preferred way of giving background layout

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/green_background" tools:context=".mainactivity" >  <textview     android:id="@+id/textview"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparenttop="true"     android:layout_centerhorizontal="true"     android:text="revision"     android:textsize="60sp" />  <button     android:id="@+id/button"     android:layout_width="150dp"     android:layout_height="80dp"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true"     android:layout_aligntop="@+id/button2"     android:background="#d1131110"     android:clickable="true"     android:text="button_work"     android:textcolor="#ffe7e7e7"     android:textsize="30sp" />  <button     android:id="@+id/button2"     android:layout_width="150dp"     android:layout_height="80dp"     android:layout_alignparentend="true"     android:layout_alignparentright="true"     android:layout_below="@+id/textview"     android:layout_margintop="59dp"     android:background="#d1131110"     android:clickable="true"     android:text="button_break"     android:textcolor="#ffe7e7e7"     android:textsize="30sp" />  <chronometer     android:id="@+id/chronometer"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/button"     android:layout_alignstart="@+id/button"     android:layout_below="@+id/button"     android:layout_margintop="180dp"     android:textsize="50sp" />  <chronometer     android:id="@+id/chronometer2"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentend="true"     android:layout_alignparentright="true"     android:layout_aligntop="@+id/chronometer"     android:textsize="50sp" /> 

note image view removed , background entire layout applied single line of code android:background="@drawable/green_background" in relative layout


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -