本文介绍了如何使Android应用程序的背景图像重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设置背景图片在我的应用程序,但背景图像小,我希望它重演,并利用整个屏幕。我该怎么办?
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@可绘制/ BG
机器人:TILEMODE =重复>
解决方案
好了,这里就是我有我的应用程序。它包括一个黑客以prevent 的ListView
- 从去黑色,而滚动。
绘制/ app_background.xml
< XML版本=1.0编码=UTF-8&GT?;
<位图的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:SRC =@可绘制/ actual_pattern_image
机器人:TILEMODE =重复/>
值/ styles.xml
< XML版本=1.0编码=UTF-8&GT?;
<资源>
<样式名称=App_Theme文件父=安卓主题>
<项目名称=机器人:windowBackground> @可绘制/ app_background< /项目>
<项目名称=机器人:listViewStyle> @风格/ TransparentListView< /项目>
<项目名称=机器人:expandableListViewStyle> @风格/ TransparentExpandableListView< /项目>
< /风格>
<样式名称=TransparentListView父=@安卓风格/ Widget.ListView>
<项目名称=机器人:cacheColorHint> @android:彩色/透明< /项目>
< /风格>
<样式名称=TransparentExpandableListView父=@安卓风格/ Widget.ExpandableListView>
<项目名称=机器人:cacheColorHint> @android:彩色/透明< /项目>
< /风格>
< /资源>
AndroidManifest.xml中
//
<应用机器人:主题=@风格/ App_Theme文件>
//
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">
解决方案
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">
//
这篇关于如何使Android应用程序的背景图像重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!