【发布时间】:2015-08-08 09:08:09
【问题描述】:
我有一张分辨率为 1024x1024 像素的图像。
但是,当我尝试在我的 Android 应用(后台活动)中使用此图像时,它被压扁了。
谁能告诉我如何避免这种情况?
现在这个问题已经通过使用下面的代码解决了:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:src="@drawable/image" />
</RelativeLayout>
但此解决方案不能用于以下代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:background="@drawable/frontscreenbg"/>
<ScrollView android:id="@+id/scrollviewParentLoginContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/linearLayoutLoginContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="24dp"
android:paddingRight="24dp">
请帮帮我。
【问题讨论】:
-
您可以通过在后台使用
ImageView和android:scaleType="centerCrop"来实现此目的 -
到底想要什么
-
@zkminusck 我是使用 ImageView 的机器人,我正在尝试设置 Relaytive Layout 的背景。
-
@Albert,您已经为多设备屏幕支持制作了各种图像,请查看:stackoverflow.com/questions/19875158/…
-
我们没有其他选择吗?
标签: android image android-image android-background