0
A
回答
0
我认为最好的方法是使用所有你的意见(有可能用的FrameLayout),这里是你的XML后面的ImageView的: (你可以使用不同的scaleType)
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@mipmap/background"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- put your views here -->
</RelativeLayout>
</FrameLayout>
0
以编程方式,你可以这样做。 在不同的活动中,您可以使用相同的布局文件。 为您的布局命名: - myLayout 为布局定义一个变量。 受保护的视图myLayoutView; 阅读布局作为视图 myLayoutView =(查看)findViewById(R.id.myLayout); 然后设置背景如下: myLayoutView.setBackground((Drawable)myBackground);
以上所有内容都是在您的活动的onCreate方法中编写的。您可以随时更改背景。
布局中可能有其他几个视图可能会在屏幕上显示其内容,也可能存在动画,但背景仍保持静态。
相关问题
- 1. 如何为UIWebView添加背景图片?
- 2. 如何在Android Studio中为背景添加动画效果?
- 3. Cocos2d为图层添加背景图片?
- 4. 如何添加内联背景图片?
- 5. 如何动态添加背景图片?
- 6. 如何添加图片作为表格单元格背景
- 7. 在vim中添加背景图片
- 8. 在css中添加背景图片
- 9. 在pygames中添加背景图片?
- 10. 如何在Android中添加圆角作为Recyclerview的背景
- 11. Android Studio - 更改背景图片大小
- 12. Java如何在布局中添加图像作为背景
- 13. 如何将背景图片添加到Android活动?
- 14. 如何在android中为achartengine折线图设置背景图片?
- 15. 在TextView后面添加背景图片
- 16. 在安卓graphview添加背景图片
- 17. Reportlab:添加图像作为背景
- 18. 如何在android studio中加载背景图片时减少延迟?
- 19. Android:背景图片
- 20. 在工具栏的背景添加图片中的Android
- 21. 如何在模板中添加背景图片
- 22. 如何在Angular 2组件中添加背景图片?
- 23. 如何使用jquery在文本框中添加背景图片
- 24. 如何在wordpress3.5.1中添加背景图片
- 25. 如何在检票中添加表格背景图片
- 26. 如何在Joomla 3x中添加完整宽度背景图片
- 27. 如何在symfony中设置/添加背景图片
- 28. 如何添加滚动视图中的背景图片
- 29. 如何为背景图片添加边距?
- 30. 如何为IE 8添加CSS背景图片?对于DIV