视图周围的边界

Boundry around a view

我想要图像中显示的视图周围的边界:

https://projects.invisionapp.com/share/785LXW0SQ#/screens/137849056

我的 xml 文本视图上方的布局代码 "calling":

 <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_alignParentTop="true"
                android:id="@+id/cardview0"
                >
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
                <TextView
                    android:textColor="#3B64AE"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Circle"
                    android:layout_marginLeft="30dp"
                    android:layout_gravity="center_vertical"
                    android:layout_centerVertical="true"
                    />

                <Spinner
                    android:layout_alignParentEnd="true"
                    android:layout_width="150dp"
                    android:layout_height="match_parent">


                </Spinner>

</RelativeLayout>


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

Suppose i want a boundary around this card view.How can i do it?

试试这个:

卡片视图内的边界线:

 <android.support.v7.widget.CardView
        android:id="@+id/cardview0"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:background="#000000">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="0.5dp"
                android:layout_marginLeft="0.5dp"
                android:layout_marginTop="0.5dp"
                android:background="#ffffff">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="30dp"
                    android:text="Circle"
                    android:textColor="#3B64AE" />

                <Spinner
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:layout_alignParentRight="true">


                </Spinner>

            </RelativeLayout>
        </RelativeLayout>

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

卡片视图外的边界线:

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginLeft="5dp"
        android:background="@drawable/border_line">

        <android.support.v7.widget.CardView
            android:id="@+id/cardview0"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_margin="1dp"
            android:layout_alignParentTop="true">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#ffffff">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="30dp"
                    android:text="Circle"
                    android:textColor="#3B64AE" />

                <Spinner
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:layout_alignParentRight="true">


                </Spinner>

            </RelativeLayout>


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

    </RelativeLayout>

可绘制 -> border_line.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <stroke
        android:width="2dp"
        android:color="000000" />

</shape>