本文介绍了如何使应用程序的背景图像重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用中设置了背景图片,但背景图片很小,我想重复它并填写整个屏幕。我该怎么办?
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">
推荐答案
好的,这是我在我的应用程序中得到的内容。它包括一个黑客,以防止 ListView
在滚动时变黑。
Ok, here's what I've got in my app. It includes a hack to prevent ListView
s 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">
//
这篇关于如何使应用程序的背景图像重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!