Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an app's background image repeat

I have set a background image in my app, but the background image is small and I want it to be repeated and fill in the whole screen. What should I do?

<LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="@drawable/bg"     android:tileMode="repeat"> 
like image 655
virsir Avatar asked Apr 25 '10 02:04

virsir


People also ask

What is background-repeat no-repeat?

The background-repeat property in CSS is used to repeat the background image both horizontally and vertically. It also decides whether the background-image will be repeated or not. Syntax: background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial| inherit; Default Value: Its default value is initial.

How would you set a background image to not repeat?

To make a background image not repeat in HTML, specify no-repeat in the background-repeat property or the background shorthand property. The background image is set to 'no-repeat' using the 'background-repeat' property.

How do you repeat a picture on android?

Define your repeating image as Drawable (bitmap) with android:tileMode="repeat" in XML and use it as background of your RelativeLayout .


1 Answers

Ok, here's what I've got in my app. It includes a hack to prevent ListViews from going black while scrolling.

drawable/app_background.xml:

<?xml version="1.0" encoding="utf-8"?>     <bitmap xmlns:android="http://schemas.android.com/apk/res/android"         android:src="@drawable/actual_pattern_image"         android:tileMode="repeat" /> 

values/styles.xml:

<?xml version="1.0" encoding="utf-8"?> <resources>    <style name="app_theme" parent="android:Theme">     <item name="android:windowBackground">@drawable/app_background</item>     <item name="android:listViewStyle">@style/TransparentListView</item>     <item name="android:expandableListViewStyle">@style/TransparentExpandableListView</item>   </style>    <style name="TransparentListView" parent="@android:style/Widget.ListView">     <item name="android:cacheColorHint">@android:color/transparent</item>   </style>    <style name="TransparentExpandableListView" parent="@android:style/Widget.ExpandableListView">     <item name="android:cacheColorHint">@android:color/transparent</item>   </style>  </resources> 

AndroidManifest.xml:

// <application android:theme="@style/app_theme"> // 
like image 54
yanchenko Avatar answered Sep 30 '22 01:09

yanchenko