Android滚动视图/背景图像/Xamarin
我想创建一个背景图像大小大于屏幕的滚动视图来做“长滚动页面”应用程序。我正在使用以下XML进行布局:Android滚动视图/背景图像/Xamarin,android,xamarin,scrollview,Android,Xamarin,Scrollview,我想创建一个背景图像大小大于屏幕的滚动视图来做“长滚动页面”应用程序。我正在使用以下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"
<?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)
问题:
如果我使用滚动视图标签,为什么跑步应用程序上的背景总是调整为屏幕大小
我想要实现的目标:
同样的效果如下:
测试环境
Nexus 4 simulator可滚动内容是
ScrollView
中的任何内容。在这种情况下,您只需在ScrollView
中创建一个ImageView
,并将src
属性设置为@drawable/Wallper
:
<?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”,因为这是常用的命名方式,尝试在您的scrollView中添加一个ImageView,并将该图像视图的图像源设置为您的背景图像我尝试了此解决方案,现在我可以滚动,但图像仍然被压缩(图像上方和下方有黑色条纹)所以滚动不是在图像上,而是在图像+布局上。我应该为图像设置一些宽度、高度属性来避免这种情况吗?