我想创建背景图像尺寸大于屏幕的滚动视图做一种"长滚动页"应用程序。我使用以下XML布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="match_parent"
p1:layout_height="match_parent"
p1:id="@+id/relativeLayout1">
<ScrollView
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="wrap_content"
p1:layout_height="wrap_content"
p1:id="@+id/scrollView1"
p1:background="@drawable/wallpaper"
/>
</RelativeLayout>
我的壁纸(背景图片大小为1920x820)。
问题:为什么我的背景运行的应用程序总是调整到屏幕大小,如果我使用滚动视图标签?
我想要达到的目标:效果和下面一样:http://developer.xamarin.com/recipes/ios/content_controls/scroll_view/use_a_scrollview/
测试env Nexus 4模拟器
可滚动内容是ScrollView
内部的任何内容。在本例中,您所要做的就是在ScrollView
中创建一个ImageView
,并将其src
属性设置为@drawable/wallpaper
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="match_parent"
p1:layout_height="match_parent"
p1:id="@+id/relativeLayout1">
<ScrollView
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="wrap_content"
p1:layout_height="wrap_content"
p1:id="@+id/scrollView1">
<ImageView
p1:layout_width="wrap_content"
p1:layout_height="wrap_content"
p1:src="@drawable/wallpaper"/>
</ScrollView>
</RelativeLayout>
Ps:我也会把"p1"改成"android",因为这是常见的命名方式,避免使用px