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. 如何为ActionBar添加背景图片?
- 2. 如何为UIWebView添加背景图片?
- 3. 如何在Android Studio中为背景添加动画效果?
- 4. 如何在android中添加图片背景opengl
- 5. 如何在Android的paint class中添加背景图片?
- 6. Cocos2d为图层添加背景图片?
- 7. 如何添加内联背景图片?
- 8. 如何动态添加背景图片?
- 9. 如何添加背景图片
- 10. 如何添加图片作为表格单元格背景
- 11. 在vim中添加背景图片
- 12. 在css中添加背景图片
- 13. 在pygames中添加背景图片?
- 14. 如何在背景图片上添加填充? | Android
- 15. 如何为Android设置背景图片?
- 16. 如何在Android中添加圆角作为Recyclerview的背景
- 17. 添加背景图片并在图片上添加文字
- 18. 如何为选择框中的选项添加背景图片?
- 19. SVG作为背景图片?
- 20. 作为背景图片
- 21. Android Studio - 更改背景图片大小
- 22. 如何将twitter-bootstrap图标添加为CSS背景图片?
- 23. Java如何在布局中添加图像作为背景
- 24. 如何在Chartjs中添加图像作为背景?
- 25. JLabel作为背景图片
- 26. 无法添加图案作为背景图片播放框架
- 27. 如何在打印时在JTable中添加背景图片?
- 28. 如何将背景图片添加到Android活动?
- 29. 如何在android中为achartengine折线图设置背景图片?
- 30. 在边缘内添加背景图片