我遇到以下问题;
我有一个LinearLayout在其中一个ScrollView,在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>
解决方法
尝试使用FrameLayout与ImageView和LinearLayout里面.例如,尝试更改图像的alpha并将其移动到FrameLayout中的前景,因此LinearLayout将保留在背景上.希望这可以帮助!