码迷,mamicode.com
首页 > 移动开发 > 详细

android用shape给linearLayout设置边框,怎样只保留底部或顶部的边框,把其它三个方向的边框去掉呢?

时间:2014-10-08 17:34:55      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:android   http   color   io   ar   sp   c   问题   on   


====================问题描述====================
下面是我的测试代码,最终效果LinearLayout有灰色边框,要怎样保留底部或顶部的边框,其它三个方向的边框去掉?
boder.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <stroke  
        android:width="0.01dp"  
        android:color="#C6C7CE" />
    <padding  
        android:bottom="5dp"   
        android:top="5dp"
        android:left="5dp"
        android:right="5dp" />

</shape>


text.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent" >

    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:orientation="vertical" android:gravity="center"
        android:background="@drawable/boder" >
        
        <TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:text="@string/log_name"/>
            
    </LinearLayout>

 </LinearLayout>

====================解决方案1====================
<padding  
        android:bottom="5dp"   
        android:top="5dp"
        android:left="5dp"
        android:right="5dp" />
左右为0不就行了
====================解决方案2====================
可以附带效果图,这样会跟更好分析点

android用shape给linearLayout设置边框,怎样只保留底部或顶部的边框,把其它三个方向的边框去掉呢?

标签:android   http   color   io   ar   sp   c   问题   on   

原文地址:http://www.cnblogs.com/liangxieliang56/p/4011106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!