Consultation Background image Android

1

I wanted to know how I can set up a background image, so that it looks on absolutely the whole screen, take out the ActionBar and I want to put the transparent notification bar so that the image can be seen there too. Thanks in advance.

I had tried:

<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/background"/>
    
asked by Nicolas Schmidt 05.04.2016 в 19:31
source

2 answers

2

Several options, the first one would be defining as background an image through the property android:background

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:background="@drawable/mi_fondo">
</RelativeLayout>

The second, using a ImageView with properties, android:layout_width="match_parent" and android:layout_height="match_parent" , defining an image with property android:background :

<ImageView
    android:id="@+id/myImageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/mi_fondo"/>

the third one using an ImageView, using the property android:scaleType="fitXY" :

   <ImageView
            android:id="@+id/Load_img_splash"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@null"
            android:scaleType="fitXY"                            
            android:src="@drawable/mi_imagen" />

and the fourth, defining a theme, where you define the image:

<style name="miFondo" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowBackground">@drawable/mi_fondo</item>
    <item name="android:windowNoTitle">true</item>
</style>

and you load it from your activity, defining the theme in AndroidManifest.xml

 <activity android:name=".MainActivity"
        android:theme="@style/miFondo"></activity>

    
answered by 05.04.2016 / 19:38
source
0

For the background image, give a Layout background with android:background="@drawable/background_game_screen" , example:

<LinearLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@drawable/background_game_screen"

For the transparency of the notification bar, try placing this in your theme:

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>

And if you want to remove the ActionBar, do it with this:

android:theme="@android:style/Theme.NoTitleBar"

or through the code:

ActionBar actionBar = getActionBar(); //o en su caso getSupportActionBar();
actionBar.hide();
    
answered by 05.04.2016 в 19:40