如何解决线性布局中的背景图像尺寸不合适
| 我用背景图像,png制作了线性布局...我不知道如何将其显示在布局中(居中)并保持比例...这是代码<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/background\">
显然图像的显示高度和宽度相同...有什么帮助吗?提前致谢
= .4.S。=
解决方法
尝试以下相关问题/答案:
Android:缩放可绘制或背景图像?
我没有尝试过,但这听起来与您在说的相似。
, 谢谢大家^^我是这样解决的:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\">
<ImageView xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:src=\"@drawable/background\"
android:layout_gravity=\"center\"/>
<ListView android:id=\"@+id/android:list\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:divider=\"#FFFFFF\"
android:layout_weight=\"2\"
android:drawSelectorOnTop=\"false\"
android:layout_gravity=\"center\"/>
</FrameLayout>
, 如果您不希望拉伸图片,可以使用重力设置为BitmapDrawable而不是png的图片。
参考文档:位图
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。