Roy Doron Roy Doron - 24 days ago 6
Android Question

Dynamic CardViews inside a Grid alike view

I am trying to create different patterns of CardViews, align them horizontally and vertically and put them inside one big LinearLayout, in order to achieve the following:

enter image description here

I have created the first and the last Card views, but I am having trouble creating the cardviews in between, with all their features such as: the vertical divider, and the cut in the edges horizontal divider between the first and the second cardviews.

(**red Scissors and the blue circle are png's)

I am open to any other suggestions that may accomplish this commplicated "GridView" alike xml code.

I added my xml code:

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/screen_backround_color"
android:orientation="vertical"
android:layout_weight="100">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="@drawable/frame_border"
android:orientation="vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_weight="90">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:contentPadding="15dp"
card_view:cardUseCompatPadding="true"
android:id="@+id/MainFormFirstRow">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:orientation="horizontal">

<!--Model Name-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Model Name"
android:textColor="#ec1c24"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/editTextModelName"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#666666"
android:textSize="30dp"
android:textStyle="bold"/>
</LinearLayout>
<!--Serial Number, IP Address, Version-->
<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<TableRow>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="Model ID:"
android:textColor="#ec1c24"
android:textSize="14dp"
android:textStyle="bold"/>

<TextView
android:id="@+id/editTextModelId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#666666"/>
</TableRow>

<TableRow>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:text="IP:"
android:textColor="#ec1c24"
android:textSize="14dp"
android:textStyle="bold"/>

<TextView
android:id="@+id/editTextIPAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#666666"/>
</TableRow>

<TableRow>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:text="BS Version:"
android:textColor="#ec1c24"
android:textSize="14dp"
android:textStyle="bold"/>

<TextView
android:id="@+id/editTextPLC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#666666"/>
</TableRow>

</TableLayout>

</LinearLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:contentPadding="15dp"
card_view:cardUseCompatPadding="true"
android:id="@+id/MainFormSecondRow">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_horizontal"
android:orientation="horizontal">

<!--IOMapping1-->
<LinearLayout
android:id="@+id/tableRowIOMapping1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal">

<TextView
android:id="@+id/textViewIOMapping1"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temperature"
android:textColor="#6d6e70"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="@+id/editTextIOMapping1"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#8bc53f"
android:textSize="30dp"
android:textStyle="bold"
android:enabled="false"/>
</LinearLayout>
<!--IOMapping2-->
<LinearLayout
android:id="@+id/tableRowIOMapping2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal">

<TextView
android:id="@+id/textViewIOMapping2"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pressure"
android:textColor="#6d6e70"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="@+id/editTextIOMapping2"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#8bc53f"
android:textSize="30dp"
android:textStyle="bold"
android:enabled="false"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:contentPadding="15dp"
card_view:cardUseCompatPadding="true"
android:layout_marginBottom="1dp"
android:id="@+id/MainFormThirdRow">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_horizontal"
android:orientation="horizontal">

<!--Current Cycle Name-->
<LinearLayout
android:id="@+id/tableRowIOMapping1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewCycleName"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Current Cycle Name"
android:textColor="#6d6e70"
android:textSize="16dp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/editTextCycleName"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="@+id/TwitterImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:src="@drawable/icon">
</ImageView>
<TextView
android:id="@+id/editTextCycleName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff0000"
android:layout_weight="1"
android:textSize="16dp"
android:textStyle="bold"
android:enabled="false"/>
</LinearLayout>
</LinearLayout>
<!--System Status-->
<LinearLayout
android:id="@+id/tableRowIOMapping2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/tableRowIOMapping2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/textViewSystemStatus"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="System Status"
android:textColor="#6d6e70"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/editTextSystemStatus"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#8bc53f"
android:textSize="20dp"
android:textStyle="bold"
android:enabled="false"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:contentPadding="15dp"
card_view:cardUseCompatPadding="true"
android:layout_marginBottom="1dp"
android:id="@+id/MainFormFirstRow">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:orientation="horizontal">

<!--Cycle Stage-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="100"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
android:id="@+id/textViewRefTemperature"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:text="Cycle Stage"
android:textColor="#ec1c24"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/editTextCycleStage"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_weight="20"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#231f20"
android:textSize="30dp"
android:textStyle="bold"/>

<ImageView
android:id="@+id/FacebookImage"
android:layout_weight="70"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:src="@drawable/icon">
</ImageView>
</LinearLayout>

<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<!--Door State-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
android:id="@+id/textViewChamberTemperature"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Model Name"
android:textColor="#ec1c24"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/editTextDoorState"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff0000"
android:textSize="20dp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<!--Cycle Error-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
android:id="@+id/textViewRefTemperature"
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Model Name"
android:textColor="#6d6e70"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/editTextCycleError"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff0000"
android:textSize="30dp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
</TableLayout>

</LinearLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:contentPadding="15dp"
card_view:cardUseCompatPadding="true"
android:layout_marginBottom="1dp"
android:id="@+id/MainFormSixtRow">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center_vertical"
android:orientation="horizontal">

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ster. Temp:"
android:textColor="#6d6e70"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/plc_ModelName"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#231f20"
android:textSize="30dp"
android:textStyle="bold"/>
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ster. Time:"
android:textColor="#ec1c24"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/plc_ModelName"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#666666"
android:textSize="30dp"
android:textStyle="bold"/>
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
style="@style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dry Time:"
android:textColor="#ec1c24"
android:textSize="16dp"
android:textStyle="bold" />

<TextView
android:id="@+id/plc_ModelName"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#666666"
android:textSize="30dp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

</LinearLayout>

</LinearLayout>
</LinearLayout>


thank you for your help.

Answer

After hard work of using CardView, android:layout_below and studying on Vertical and Horizontal Dividers, I got a solution. the following Cardview (it could be in a LinearLayout as well) contains the above mockup:

          <android.support.v7.widget.CardView
              xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:card_view="http://schemas.android.com/apk/res-auto"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:gravity="center_vertical"
              android:orientation="vertical"
              android:id="@+id/MainFormThirdRow"
              card_view:cardCornerRadius="0dp"
              card_view:cardElevation="0dp"
              card_view:contentPadding="10dp"
              card_view:cardBackgroundColor="@android:color/white"
              android:layout_below="@+id/Divider2">

            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

              <LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="2"
                  android:orientation="horizontal">

                <!--Cycle Name-->  <!--Cycle Stage-->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"
                    android:gravity="center_vertical"
                    android:orientation="vertical">

                  <!--Cycle Name-->
                  <LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:gravity="center_vertical"
                      android:orientation="vertical">

                    <TextView
                        android:id="@+id/textViewCycleName"
                        style="@style/Base.TextAppearance.AppCompat.Headline"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Current Cycle Name"
                        android:textColor="#6d6e70"
                        android:textSize="15dp"/>

                    <LinearLayout
                        android:id="@+id/tableRowIOMapping1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="horizontal"
                        android:padding="5dp">
                      <!--Cycle Image-->
                      <ImageView
                          android:id="@+id/CycleImage"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginRight="10dp">
                      </ImageView>
                      <TextView
                          android:id="@+id/editTextCycleName"
                          style="@style/Base.TextAppearance.AppCompat.Body1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="Cycle Value"
                          android:textColor="#ff0000"
                          android:textSize="17dp"
                          android:paddingTop="5dp"
                          android:maxLines="2"
                          android:ellipsize="end"/>
                    </LinearLayout>
                  </LinearLayout>

                  <!--Divider-->
                  <View
                        android:layout_width="match_parent"
                        android:background="@drawable/HalfHorizontalDivider"
                        android:layout_height="1dp"/>

                  <!--Cycle Stage--> 
                  <LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:gravity="center_vertical"
                      android:orientation="vertical">

                    <LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_weight="1"
                      android:gravity="center_vertical"
                      android:orientation="vertical">
                      <TextView
                          android:id="@+id/textViewCycleStage"
                          style="@style/Base.TextAppearance.AppCompat.Headline"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="Cycle Stage"
                          android:textColor="#6d6e70"
                          android:textSize="15dp"
                          android:gravity="center_horizontal"/>
                      <LinearLayout
                          android:id="@+id/tableRowIOMapping1"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:layout_weight="1"
                          android:orientation="vertical"
                          android:paddingLeft="30dp">
                        <TextView
                          android:id="@+id/editTextCycleStage"
                          style="@style/Base.TextAppearance.AppCompat.Body1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="Cycle Stage Value"
                          android:textColor="#231f20"
                          android:textSize="15dp"
                          android:textStyle="bold"
                          android:ellipsize="end"/>
                        <!--Cycle Image-->
                        <WebView
                            xmlns:android="http://schemas.android.com/apk/res/android"
                             android:id="@+id/MyWebView"
                             android:layout_width="100dp"
                             android:layout_height="100dp"/>
                      </LinearLayout>
                    </LinearLayout>

                  </LinearLayout>

                </LinearLayout>
                </LinearLayout>

                <!--Vertical Divider-->
                <View
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="@drawable/FullVerticalDivider"/>

                <!--System Status-->  <!--Door State-->  <!--Cycle Error-->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:layout_marginLeft="5dp">

                  <LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_weight="3"
                  android:gravity="center_vertical"
                  android:orientation="vertical">
                    <!--System Status-->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:layout_weight="1">

                      <TextView
                          android:id="@+id/textViewSystemStatus"
                          style="@style/Base.TextAppearance.AppCompat.Headline"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="System Status"
                          android:textColor="#6d6e70"
                          android:textSize="15dp"/>

                      <TextView
                          android:id="@+id/editTextSystemStatus"
                          style="@style/Base.TextAppearance.AppCompat.Body1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="System Value"
                          android:textColor="#ff0000"
                          android:textSize="20dp"
                          android:padding="5dp"
                          android:maxLines="2"
                          android:ellipsize="end"/>
                    </LinearLayout>

                    <!--Divider-->
                    <View
                          android:layout_width="match_parent"
                          android:background="@drawable/HalfHorizontalDivider"
                          android:layout_height="1dp"/>

                    <!--Door State-->
                    <LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:orientation="vertical"
                          android:layout_weight="1">

                      <TextView
                          android:id="@+id/textViewDoorState"
                          style="@style/Base.TextAppearance.AppCompat.Headline"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="Door State"
                          android:textColor="#6d6e70"
                          android:textSize="15dp"
                          android:ellipsize="end"
                          android:maxLines="1"/>

                      <TextView
                          android:id="@+id/editTextDoorState"
                          style="@style/Base.TextAppearance.AppCompat.Body1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="Door State Value"
                          android:textColor="#ff0000"
                          android:textSize="20dp"
                          android:padding="5dp"
                          android:ellipsize="end"/>
                    </LinearLayout>

                    <!--Divider-->
                    <View
                          android:layout_width="match_parent"
                          android:background="@drawable/HalfHorizontalDivider"
                          android:layout_height="1dp"/>

                    <!--Cycle Error-->
                    <LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:orientation="vertical"
                          android:layout_weight="1">

                      <TextView
                          android:id="@+id/textViewCycleError"
                          style="@style/Base.TextAppearance.AppCompat.Headline"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:textColor="#6d6e70"
                          android:textSize="15dp"/>

                      <TextView
                          android:id="@+id/editTextCycleError"
                          style="@style/Base.TextAppearance.AppCompat.Body1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:textColor="#ff0000"
                          android:textSize="20dp"
                          android:padding="5dp"
                          android:ellipsize="end"
                          android:maxLines="1"/>
                    </LinearLayout>

                  </LinearLayout>

                </LinearLayout>

            </LinearLayout>
            </LinearLayout>
          </android.support.v7.widget.CardView>

Vertical Divider:

     <shape xmlns:android="http://schemas.android.com/apk/res/android" >
        <size android:width="1dp"/>
        <solid android:color="#989898"/>
      </shape>

Horizontal Divider:

      <?xml version="1.0" encoding="utf-8"?>
      <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
        <item>
          <shape android:shape="rectangle" >
            <solid android:color="@android:color/white" />
          </shape>
        </item>


        <item
            android:left="10dp"
            android:right="10dp">
          <shape android:shape="rectangle" >
            <solid android:color="#989898"/>
          </shape>
        </item>

      </layer-list>

I hope it will be of use.