【发布时间】:2015-06-29 14:37:56
【问题描述】:
我有一个 android 活动,其中有一个覆盖背景图像的图像。 2 个图像必须对齐(仅高度),因此不得缩放背景图像的高度。 但是,在宽显示器上,我需要拉伸此背景的宽度以适合屏幕。 目前我已经这样设置了Activity背景。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layRoot"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/meditation_bg">
meditation_bg 是一个可绘制的资源。代码是
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/morn_blur_bg"
android:gravity="top|center"
android:scaleType="centerCrop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
需要位图可绘制资源以防止操作系统为我缩放图像。
如何在不影响图片高度的情况下控制宽度。
干杯,
【问题讨论】:
-
我真的不明白你真正需要实现什么......
-
嗨,我需要在不影响高度的情况下拉伸背景图像的宽度。高度必须保持不变。