Android Build a Simple Android App Creating the Screen Layout Adding a Button

Chan Yu
Chan Yu
150 Points

Our Properties button on right side

I am using window 10. As the properties part show in video is not same with my android studio vision. I cannot show the same properties list in video. Say i don't have layoutwidth and height. But i have layout Direction and other things i don't know on that.

1 Answer

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Hey Chan!

Yep, the Properties field has changed a little bit. Also, they've changed the default layout from RelativeLayout to ConstraintLayout which I think is the issue you're having. Instead of a ConstraintLayout, you should be using a RelativeLayout.

Here's the layout I used if you'd like to take a look:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:padding="16dp"
    tools:context=".FunFactsActivity"
    android:background="#51b46d"
    android:id="@+id/relativeLayout">

    <TextView android:text="Did you know?" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24sp"
        android:textColor="#80ffffff" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ants stretch when they wake up in the morning."
        android:id="@+id/factTextView"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textSize="24sp"
        android:textColor="@android:color/white" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Show Another Fun Fact"
        android:id="@+id/showFactButton"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@android:color/white"
        android:textColor="#51b46d" />

</RelativeLayout>