how to add background image to activity?
use the android:background
attribute in your xml. Easiest way if you want to apply it to a whole activity is to put it in the root of your layout. So if you have a RelativeLayout as the start of your xml, put it in here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootRL"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background">
</RelativeLayout>
Full screen background image in an activity
There are several ways you can do it.
Option 1:
Create different perfect images for different dpi and place them in related drawable folder. Then set
android:background="@drawable/your_image"
Option 2:
Add a single large image. Use FrameLayout. As a first child add an ImageView
. Set the following in your ImageView.
android:src="@drawable/your_image"
android:scaleType = "centerCrop"
android add background image to activity
i had a similar problem , its for low heap memory on some phones.
try reducing the image resolution then recompile it.
reduce resolution to something like 200*100 or similar.
did help me , hope help you too.
set an image background on a scrolling activity
change the background attribute of android.support.design.widget.CollapsingToolbarLayout
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:background="@drawable/backgraound">
or change the background attribute of android.support.design.widget.AppBarLayout
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"
android:background="@drawable/backgraound">
Related Topics
Convert Image to PDF in Android
Android Active Link of Url in Textview
How to Install/Update/Remove APK Using "Packageinstaller" Class in Android L
Combining Two Bitmap Image (Side by Side)
How to Hide "Navigation" and "Gps Pointer" Buttons When I Click The Marker on The Android Google Map
Export The Contacts as Vcf File
Activitymanager.Getrunningtasks Is Deprecated Android
Pdf Library for Android - Pdfbox
How to Look-Up a Contact's Name from Their Phone Number on Android
Make Android Webview Not Store Cookies or Passwords
Android Understanding Heap Sizes
How to Find The Amount of Free Storage (Disk Space) Left on Android
How to Set Proxysettings and Proxyproperties on Android Wi-Fi Connection Using Java
When to Use Fragmentmanager::Putfragment and Getfragment
Ionic Cordova App Stopped Compiling After Google's June 17Th Firebase Sdk Update