2018/11/16

Android UI, Line Layout in Constrait Layout

This example show 6 line layout containers in a constraint layout, looks like below:



The layout XML is like


<?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:id="@+id/start"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.start.StartFragment">
<!-- row 1 -->
<LinearLayout
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="100dp" android:id="@+id/linearLayout_1"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="50dp"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/linearLayout_2"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:text="TextView1"
android:layout_width="match_parent"
android:layout_height="54dp" android:id="@+id/textView1"/>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/button55"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/linearLayout_2"
app:layout_constraintStart_toEndOf="@+id/linearLayout_1"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toStartOf="@+id/linearLayout_3"
app:layout_constraintTop_toTopOf="@+id/linearLayout_1">
<TextView
android:text="TextView2"
android:layout_width="match_parent"
android:layout_height="54dp" android:id="@+id/textView2"/>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/button66"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/linearLayout_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/linearLayout_2" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintTop_toTopOf="@+id/linearLayout_2">
<TextView
android:text="TextView3"
android:layout_width="match_parent"
android:layout_height="54dp" android:id="@+id/textView3"/>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/button77"/>
</LinearLayout>
<!-- row 2 -->
<LinearLayout
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="100dp" android:id="@+id/linearLayout_4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/linearLayout_5" android:layout_marginTop="120dp"
app:layout_constraintTop_toBottomOf="@+id/linearLayout_1">
<TextView
android:text="TextView4"
android:layout_width="match_parent"
android:layout_height="54dp" android:id="@+id/textView4"/>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/button5"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/linearLayout_5"
app:layout_constraintStart_toEndOf="@+id/linearLayout_4"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toStartOf="@+id/linearLayout_6"
app:layout_constraintTop_toTopOf="@+id/linearLayout_4">
<TextView
android:text="TextView5"
android:layout_width="match_parent"
android:layout_height="54dp" android:id="@+id/textView5"/>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/button6"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/linearLayout_6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/linearLayout_5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintTop_toTopOf="@+id/linearLayout_5">
<TextView
android:text="TextView6"
android:layout_width="match_parent"
android:layout_height="54dp" android:id="@+id/textView6"/>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/button7"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

1 comment:

  1. Baccarat - Why I Found This Bookie
    How much do you have to bet on on a casino? You'll get 바카라 사이트 more money to spend 샌즈카지노 if you are playing at a baccarat casino. The only thing missing is งานออนไลน์ a few

    ReplyDelete

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...