【发布时间】:2018-09-11 00:40:07
【问题描述】:
我遇到以下问题;
我有一个带有 ScrollView 的 LinearLayout,在 ScrollView 中有一些自定义视图。现在我想在 LinearLayout 的背景中放置一个图像,并保持图像的原始大小。但是当我设置 LinearLayout 的背景属性时,它会拉伸以适应全屏。我怎样才能使图像保持其原始大小?
我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/some_drawable">
<ScrollView
android:id="@+id/scrollview"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:fillViewport="true">
<some.custom.layout
android:id="@+id/mainLayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
</ScrollView>
</LinearLayout>
【问题讨论】:
-
看到一些人时不时地支持这个问题(谢谢!),但想在这里声明一下,这个问题现在已经有 9 年了,而且在 Android 世界中发生了很多事情。现在很可能有更好的方法来解决这个问题!