android用shape给linearLayout设置边框,怎样只保留底部或顶部的边框,把其它三个方向的边框去掉呢?
下面是我的测试代码,最终效果LinearLayout有灰色边框,要怎样保留底部或顶部的边框,其它三个方向的边框去掉?
boder.xml
text.xml
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>
...全文
相关推荐
Android使用LinearLayout设置边框
LinearLayout 可以设置方向,既可以水平排列也可以垂直排列,通过设置 android:orientation 属性可以实现。
安卓高级xml输入框EditText及其登陆界面布局shape使用
通过在XML中定义shape元素,我们可以设置边框颜色、宽度、圆角半径,甚至添加渐变效果,以此来提升登录界面的视觉效果。
Android编程实现圆角边框布局效果的方法
实现圆角边框通常有两种方式:1. **XML Shape Drawable**:通过在XML文件中定义一个形状资源,可以设置`<shape>`元素的`corners`属性来实现圆角。
Android实现代码画虚线边框背景效果
这种方法不仅适用于RelativeLayout,还可以应用于其他任何支持设置背景资源的View,如LinearLayout、FrameLayout等。
Android实现给TableLayou绘制边框的方法
通过上述步骤,我们可以为TableLayout及其子组件(如TableRow或LinearLayout)添加自定义的边框。



