java - 在android布局文件中给一个LinearLayout包裹的TextView绘制分割线?
迷茫
迷茫 2017-04-18 09:34:55
[Java讨论组]

该布局如图所示,或者不绘制分割线,只要能突出TextView就行!

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(4)
大家讲道理

1.给加个背景色

2.添加分割线

'
<ImageView

    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray" />

`
3.增加视图高度
在控件中加入
android:elevation="5dp"
可以自定义

阿神

1.绘制分割线

在TextView之间放个view就可以了,高度、颜色自己设置,设成灰色较好。
<TextView/>
<View
    android:layout_width="match_parent"
    android:layout_height="0.5dp"
    android:background="@android:color/black"/>
<TextView/>

2.突出TextView也简单,设置TextView的背景色(background)与LinearLayout的背景色(background)
例如:TextView背景为白色,LinearLayout背景色为灰色。

天蓬老师

我们一般就是用view画线的宽度给个0.5dp即可

ringa_lee
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:background="#eeeeee"
              android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="创建的社团"
        android:textSize="16sp"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:paddingLeft="30dp"
        android:background="@android:color/white"
        android:layout_marginTop="10dp"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="加入的社团"
        android:textSize="16sp"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:paddingLeft="30dp"
        android:background="@android:color/white"
        android:layout_marginTop="10dp"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="消息"
        android:textSize="16sp"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:paddingLeft="30dp"
        android:background="@android:color/white"
        android:layout_marginTop="10dp"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="设置"
        android:textSize="16sp"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:paddingLeft="30dp"
        android:background="@android:color/white"
        android:layout_marginTop="10dp"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="退出登录"
        android:textSize="16sp"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:paddingLeft="30dp"
        android:background="@android:color/white"
        android:layout_marginTop="10dp"/>
</LinearLayout>
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号