ScrollView在Android工作室工作,但不在我的智能手机上

时间:2017-06-24 14:34:26

标签: android xml scrollview

我不知道为什么它在IDE中工作但是当我在我的设备上安装apk时。 (我在RelativeLayout中有一个4000x1080像素的背景图片。)

appScreenshot

android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#f7f7f7"
android:fillViewport="true"
android:orientation="vertical">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@mipmap/space1"
    android:fillViewport="true"
    android:padding="0dp">

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="56dp"
        android:text="Hello World !"
        android:textColor="#FFFFFF"/>

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="55dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        android:background="@null"
        android:padding="5dp"
        android:scaleType="centerInside"
        app:srcCompat="@drawable/level1"
        android:gravity="center"
        android:layout_marginLeft="455px"
        android:layout_marginTop="1300px"/>


</RelativeLayout>

提前感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

尝试将大图像放在RelativeLayout内的ImageView中,而不是作为背景......并且最好使用 dp 维度单位而不是 px

答案 1 :(得分:0)

只需添加ScrollView并从RelativeLayout中删除

<...

android:fillViewport="true"

 .../>