Created
July 8, 2018 10:46
-
-
Save mochico/b52e5d3d5d967dc48200f488dde1248f to your computer and use it in GitHub Desktop.
Sample for guideline and percent in ConstraintLayout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="#fff"> | |
<android.support.constraint.Guideline | |
android:id="@+id/vertical_center_guideline" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:orientation="vertical" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintGuide_percent="0.5" | |
app:layout_constraintTop_toTopOf="parent" /> | |
<TextView | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:text="タイトル" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintEnd_toStartOf="@id/vertical_center_guideline"/> | |
<TextView | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:text="YYYY年MM月dd日" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintBottom_toBottomOf="@id/image_view" | |
app:layout_constraintEnd_toStartOf="@id/vertical_center_guideline"/> | |
<ImageView | |
android:id="@+id/image_view" | |
android:layout_width="0dp" | |
android:layout_height="0dp" | |
android:background="#999" | |
app:layout_constraintDimensionRatio="h,8:5" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="@id/vertical_center_guideline" /> | |
</android.support.constraint.ConstraintLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment