请指教如何放置一个图像作为背景LinearLayout
所以这张图片看起来像是,没有拉伸,标题或什么。如何设置背景不被拉伸?
1
A
回答
0
做出的LinearLayout android的高度和宽度为WRAP_CONTENT在.xml文件中使用此代码
android:layout_height="wrap_content"
android:layout_width="wrap_content"
设置背景图像使用代码
android:background="@drawable/image"
现在放置在图像中绘制文件
4
其他解决方案是用XML定义图像,并在背景中参考此XML:Background Image Placement
就像你可以控制你的图像(背景)布局
0
如果线性布局的内容小于图像高度,Jojo的解决方案可能会工作。 如果我添加两个或自动编辑文本图像开始拉伸。如果你仍然想避免并在后台使用imageview,请使用下面的xml布局。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton android:id="@+id/imageButton1" android:src="@drawable/icon" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@null"></ImageButton>
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="100px"></Button>
</RelativeLayout>
因为只有图像按钮的src选项在图像的宽度和高度上保持不变。
相关问题
- 1. 设置活动背景不拉伸
- 2. 不要拉伸ViewPager背景
- 3. TextView背景拉伸
- 4. UITableViewCell背景拉伸
- 5. 模拟器被拉伸的背景
- 6. 全屏背景图像被拉伸
- 7. 重复的背景图像被拉伸
- 8. 2背景拉伸1背景
- 9. 你如何拉伸背景图像
- 10. CSS - 如何拉伸菜单的背景
- 11. 设置位置顶部的拉伸背景图像
- 12. 拉伸iOS背景图像
- 13. 拉伸背景图片
- 14. 背景图像拉伸
- 15. Android背景图片拉伸
- 16. 动态拉伸UILabel背景。
- 17. 拉伸背景图像
- 18. 背景图片拉伸
- 19. Android:用背景拉伸ImageView
- 20. CSS拉伸背景图片
- 21. JS拉伸背景图像
- 22. CSS - 背景图片拉伸
- 23. UITableViewController背景图像拉伸
- 24. DIV背景不拉伸正确
- 25. 背景图像不拉伸正确
- 26. 图片设置为开关按钮的背景下被拉伸的Android
- 27. 以编程方式设置LinearLayout的背景是拉伸图像
- 28. Android,设置背景拉伸或放大,但从未正确
- 29. 裁剪图像设置为背景而无需拉伸
- 30. Xcode如何使背景位置(中心或拉伸)
他问如何确保图像不被拉伸。使用您的解决方案,如果线性布局的内容变得比图像更大,则图像将再次伸展。你如何解决这个问题? – 2014-02-04 16:58:33