How to put an fix image background for ScrollView?

2019-07-18 20:30发布

I should want the scrollview scroll, but not the image in its background.

2条回答
手持菜刀,她持情操
2楼-- · 2019-07-18 20:34

An example would be:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@drawable/background_image"
 android:orientation="vertical">

 <ListView
  android:id="@+id/category_list"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:cacheColorHint="@android:color/transparent"/>

 <TextView
  android:id="@android:id/empty"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"/>

</LinearLayout>

Here the Linearlayout holds the backround image. The list will be displayed above this with an transparent background. For further informations on this topic have a look at ListView Backgrounds

查看更多
We Are One
3楼-- · 2019-07-18 20:43

Add the image higher up the view hierarchy ahead of your scrollviews frame

查看更多
登录 后发表回答