Search code examples
androidxmlscrollview

ScrollView is working in android studio but not on my smartphone


I don't know why it is working in the IDE but when I install the apk on my device. (I have a 4000x1080 px background image in the RelativeLayout).

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>

Thank you in advance for your help.


Solution

  • Try to put the big image in an ImageView inside the RelativeLayout and not as a background ... and better to use dp dimensions units instead px