[英]how to add a background image to a scrollview with relative layout in android?
hi i have created a scrollview application with button, i have added a background image but the background works on the emulator but not on a real device, any help will be appreciated, im using an imageview as a background! 嗨,我已经创建了一个带有按钮的scrollview应用程序,我添加了一个背景图像,但是背景可以在模拟器上运行,但不能在真实设备上运行,任何帮助将不胜感激,即时通讯使用imageview作为背景!
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true"
android:orientation="vertical"
>
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="3500dp"
android:adjustViewBounds="true"
android:background="@drawable/iphonebg"
android:clickable="false"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:contentDescription="@string/background_desc"
>
</ImageView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/callButton"
android:background="@drawable/callnow1"
android:layout_marginTop="261dp"
android:onClick="callButtonClicked"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/orderButton"
android:layout_alignEnd="@+id/orderButton" />
i can scroll down its a long image and it works perfectly but on a real device the scroll is working and the buttons are in the right place just the background doesnt show? 我可以向下滚动它的长图像,并且效果很好,但是在实际设备上,滚动功能正常,按钮在正确的位置,只是背景不显示?
You should set the background image as a @drawable
XML resource. 您应该将背景图像设置为@drawable
XML资源。 That way, you can set it as the background using android:background="@drawable/..."
for whatever layout you want it to be the background of (either the ScrollView or the RelativeLayout). 这样,您可以使用android:background="@drawable/..."
将其设置为背景,以使其成为背景(无论是ScrollView还是RelativeLayout)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.