如何添加底部边框的RelativeLayout的 [英] how to add bottom border in relativelayout

查看:949
本文介绍了如何添加底部边框的RelativeLayout的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<LinearLayout 
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:orientation="vertical" android:background="@drawable/settings_border" android:padding="1dp"
            android:layout_marginLeft="15dip" android:layout_marginRight="15dip" android:layout_marginTop="5dip">
            <RelativeLayout android:id="@+id/map_refresh"
                android:layout_height="fill_parent" android:layout_width="wrap_content" 
                android:background="@drawable/settings_selector_up" 
                android:padding="15dp">
                <TextView android:id="@+id/Text1" 
                    android:layout_height="wrap_content" android:layout_width="wrap_content"
                    android:text="Map refresh period">
                </TextView>
                <TextView android:id="@+id/TextView09" 
                    android:layout_height="wrap_content" android:layout_width="wrap_content"
                    android:text="1 min" 
                    android:layout_alignParentRight="true"
                    android:paddingRight="5dp">
                </TextView>
            </RelativeLayout>

            <RelativeLayout android:id="@+id/own_location" 
                android:layout_height="fill_parent" android:layout_width="wrap_content" 
                android:padding="15dp"
                android:background="@drawable/settings_selector_mid">
                <TextView android:id="@+id/Text1" 
                    android:layout_height="wrap_content" android:layout_width="wrap_content"
                    android:text="Own location update period">
                </TextView>
                <TextView android:id="@+id/TextView09" 
                    android:layout_height="wrap_content" android:layout_width="wrap_content"
                    android:text="1 min" 
                    android:layout_alignParentRight="true"
                    android:paddingRight="5dp">
                </TextView>
            </RelativeLayout>

我想RelativeLayout的设置只有底部边框。我想dispaly列表视图样式,但不使用列表视图。可以说,每一个列表项是relativlayout。我想只设置底边框所以它看起来像一个ListView的分频器。

I want set only bottom border in relativelayout. I want to dispaly listview style but not using listview. Lets say each listitem is relativlayout. I want set only bottom border so its look like a listview's divider.

推荐答案

我希望我理解你所说的话。

I hope I understood what you said.

在资源文件夹中创建一个新的文件夹(如果你还没有拥有它)命名绘制

in the res folder create a new folder (if you don't already have it) named drawable

有创建了一个名为XMLborders.xml

there create an xml named "borders.xml"

  <selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true"><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
           <gradient android:angle="90" android:centerColor="#6da23f" android:endColor="#8bc45d" android:startColor="#2f481c" />

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

            <padding android:bottom="4dp" android:left="3dp" android:right="3dp" android:top="6dp" />

             <corners android:radius="10px"/>
        </shape></item>
    <item><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
            <gradient android:angle="90" android:centerColor="#6da23f" android:endColor="#8bc45d" android:startColor="#4c8a39" />

            <stroke android:width="1dp" android:color="#FFFFFF" />

            <padding android:bottom="4dp" android:left="3dp" android:right="3dp" android:top="6dp" />

            <corners android:radius="10px"/>
        </shape></item>

</selector>

您可以进一步编辑它,只要你喜欢。 然后,从外形布局,然后单击背景属性,然后选择您创建的边界XML。

You can further edit it as you like. Then select the layout from the Outline and click Background properties, and select the borders xml that you created.

这将为所有4.边框或者,你可以添加一个简单的

This will create borders for all 4. Alternatively, you can add a simple

<View android:layout_width="1dip"
    android:layout_height="fill_parent"
android:background="#FFFFFF" />

行并将其添加到您的布局的底部,并改变颜色/大小根据自己的喜好。

line and add it to the bottom of your layout and change the color/size to your liking.

这篇关于如何添加底部边框的RelativeLayout的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆