Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build an Interactive Story App (Retired) Finishing the User Interface Creating the Story Layout

Per Troelsen
Per Troelsen
2,634 Points

Why does all the content end up at the top of the screen?

I have set scaleType to "fitXY" and checked the "adjustViewBounds".

Am I missing something?

<ImageView android:id="@+id/storyImageView" android:layout_width="344dp" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="fitXY" app:srcCompat="@mipmap/page0" app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="8dp" android:layout_marginLeft="8dp" app:layout_constraintLeft_toLeftOf="parent"/>

<EditText
    android:id="@+id/storyTextView"
    android:layout_width="344dp"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/storyImageView"
    android:layout_alignStart="@+id/storyImageView"
    android:layout_below="@+id/storyImageView"
    android:inputType="textMultiLine"
    android:lineSpacingMultiplier="1.2"
    android:paddingLeft="15dp"
    android:paddingRight="15dp"
    android:paddingTop="15dp"
    android:text="You continue your course to Earth. Two days later, you receive a transmission from HQ saying that they have detected some sort of anomaly on the surface of Mars near an abandoned rover. They ask you to investigate, but ultimately the decision is yours because your mission has already run much longer than planned and supplies are low."
    android:textSize="14sp"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="222dp"/>

<Button
    android:id="@+id/choiceButton2"
    android:layout_width="344dp"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:text="Stop and investigate"
    android:textColor="#3abaec"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="516dp"/>

<Button
    android:id="@+id/choiceButton1"
    android:layout_width="344dp"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:text="Continue home to Earth"
    android:textColor="#3abaec"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="468dp"/>

2 Answers

Jasmeet Singh
Jasmeet Singh
20,145 Points

It looks like you're not using RelativeLayout as your root ViewGroup to populate the Views. It is ConstraintLayout. Try switching it back to RelativeLayout from ConstraintLayout to resolve the issues.

Per Troelsen
Per Troelsen
2,634 Points

Thanks Jasmeet.

I've changed the layout to relative.