Jeroen Boot
Jeroen Boot

Reputation: 47

Random white space at the right side of the scrollview

I have a problem and I can't find it on the internet. I am making an app for circus in Rome and at the following picture, I did a screenshot of the ScrollView displaying the 3 circus. But there's a strange white space at the right and when I open it on my phone I can't scroll. How can I resolve it?

enter image description here

And here is the code:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
    android:fillViewport="true"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:contextClickable="false"
    android:background="#dcda60"
    android:scrollIndicators="right"
    android:touchscreenBlocksFocus="false">

<LinearLayout 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="match_parent"
    android:layout_height="wrap_content"
    android:background="#dcda60"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:scrollIndicators="right"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="joenio.circiinrome.circi_lijst"
    tools:showIn="@layout/activity_circi_lijst"
    android:orientation="vertical">


    <ImageButton

        android:id="@+id/imageButton1"
        android:layout_width="225dp"
        android:layout_height="140dp"
        android:layout_centerHorizontal="true"
        android:background="#dcda60"
        android:scaleType="fitXY"
        android:src="@mipmap/maximus" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageButton1"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="55dp"
        android:background="#edeb67"
        android:text="@string/maximus" />

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="225dp"
        android:layout_height="110dp"
        android:background="#dcda60"
        android:scaleType="fitXY"
        android:src="@mipmap/maxentius" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="0dp"
        android:layout_marginTop="17dp"
        android:background="#edeb67"
        android:text="@string/maxentius" />

    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="225dp"
        android:layout_height="140dp"
        android:layout_gravity="center_horizontal"
        android:background="#dcda60"
        android:src="@mipmap/agionalis"
        android:scaleType="fitXY" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/agonalis"
        android:background="#edeb67" />


</LinearLayout>
</ScrollView>

Upvotes: 1

Views: 205

Answers (1)

M. Mariscal
M. Mariscal

Reputation: 1328

It seems that your android:layout_width is incorrect, you must declare on your ScrollView, and on your LinearLayout:

android:layout_width="match_parent"

instead of:

android:layout_width="wrap_content"

could it resolve your question?

Upvotes: 1

Related Questions