您的位置:首页 > 移动开发 > Android开发

android:background 图片被拉伸解决方法

2016-07-12 21:04 531 查看
使用图片给Linerlayout等做背景的时候图片会被不同程度拉伸

<LinearLayout
android:layout_width="match_parent"
android:background="@drawable/bg"
android:layout_height="match_parent"/>


我们可以在xml设置android:background属性时,使用标签

drawable/bg.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="bottom"
android:dither="true"
android:src="@mipmap/login_background"
android:tileMode="disabled"/>


android:gravity可以自行调整以适应显示效果

这样图片就不会被拉伸了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: