Step 3: Solution
This is the solution of the previous step
activity_main.xml
activity_main.xml
This is how your activity_main.xml
should look like after you finish Step 3:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="match_parent"
tools:context=".MainActivity"
android:background="@color/colorBgDark">
<android.support.v7.widget.CardView
android:id="@+id/cardview"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:cardBackgroundColor="@color/cardview_light_background"
app:cardCornerRadius="8dp"
app:cardElevation="2dp"
app:contentPadding="16dp"
app:layout_constraintBottom_toBottomOf="@id/second_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/guideline_horizontal30"
app:layout_constraintVertical_bias="0.0" >
</android.support.v7.widget.CardView>
<View
android:id="@+id/second_bg"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/colorBg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline_horizontal38" />
<!-- Guidelines -->
... ... ...
</android.support.constraint.ConstraintLayout>
For most of the layout building I'm using the design mode (and in my opinion you should as well since it's going to be much easier). That means that depending on how you move your views, the original position and many more the attributes that the editor will add can vary a bit. In my CardView
for instance there's a app:layout_constraintVertical_bias="0.0"
attribute added which you may end up not having; that's fine! Just make sure there are no warnings or errors showing up in the editor and that you're happy with the result.
Last updated