巧用TextView实现分隔线

在写这个项目的时候,需要用到分隔线,思索无果,后来想到TextView恍然大悟,一点小技巧。在在

先上效果图:

布局代码:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    tools:context="com.example.theold.MainActivity"
    tools:ignore="MergeRootFrame" >

  <LinearLayout
        android:id="@+id/linearlayoutmain"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <DigitalClock
            android:layout_weight="1"
            android:id="@+id/clock"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="70sp"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/time_bg"
            android:textColor="#000000"/>

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="30sp"
            android:fontFamily="宋体"
            android:background="#ADFF2F"
            android:id="@+id/dateandweather"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        <ImageButton
            android:layout_weight="1"
            android:src="@drawable/img_call"
            android:id="@+id/enterPhoneCall"
            android:background="@drawable/selector"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:background="#000000"
            android:layout_width="4dp"
            android:layout_height="fill_parent"/>

        <ImageButton
            android:layout_weight="1"
            android:src="@drawable/img_message"
            android:id="@+id/enterMessage"
           android:background="@drawable/selector"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />
        </LinearLayout>

        <TextView
            android:background="#000000"
            android:layout_width="fill_parent"
            android:layout_height="4dp"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        <ImageButton
            android:layout_weight="1"
            android:id="@+id/enterFlashlight"
            android:src="@drawable/img_flashlight"
            android:background="@drawable/selector"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />

        <TextView
             android:background="#000000"
            android:layout_width="4dp"
            android:layout_height="fill_parent"/>

        <ImageButton
            android:layout_weight="1"
            android:id="@+id/enterMusic"
           android:background="@drawable/selector"
           android:src="@drawable/img_music"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        </LinearLayout>

        <TextView
            android:background="#000000"
            android:layout_width="fill_parent"
            android:layout_height="4dp"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        <ImageButton
            android:layout_weight="1"
            android:id="@+id/enterCamera"
            android:src="@drawable/img_camera"
            android:background="@drawable/selector"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />

        <TextView
            android:layout_width="4dp"
            android:background="#000000"
            android:layout_height="fill_parent"/>

        <ImageButton
            android:layout_weight="1"
            android:id="@+id/enterPhotos"
            android:src="@drawable/img_photo"
           android:background="@drawable/selector"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />

        </LinearLayout>

        <TextView
            android:background="#000000"
            android:layout_width="fill_parent"
            android:layout_height="4dp"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        <ImageButton
            android:layout_weight="1"
            android:id="@+id/enterSOS"
           android:background="@drawable/selector"
            android:src="@drawable/img_sos"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />

        <TextView
            android:layout_width="4dp"
            android:background="#000000"
            android:layout_height="fill_parent"/>

        <ImageButton
            android:layout_weight="1"
            android:src="@drawable/img_compass"
            android:id="@+id/enterCompass"
           android:background="@drawable/selector"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />
        </LinearLayout>

    <TextView
            android:background="#000000"
            android:layout_width="fill_parent"
            android:layout_height="4dp"/>

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        <ImageButton
            android:id="@+id/enterAboutMore"
            android:layout_width="fill_parent"
            android:background="#2E8B57"
            android:src="@drawable/img_aboutmore"
            android:layout_height="wrap_content"/>
        </LinearLayout>

    </LinearLayout>
</ScrollView>
时间: 2024-08-08 09:38:11

巧用TextView实现分隔线的相关文章

CSS分隔线

单个标签实现分隔线: .demo_line_01{ padding: 0 20px 0; margin: 20px 0; line-height: 1px; border-left: 200px solid #ddd; border-right: 200px solid #ddd; text-align: center; } 优点:代码简洁 巧用背景色实现分隔线: .demo_line_02{ height: 1px; border-top: 1px solid #ddd; text-align

CSS巧妙实现分隔线的几种方法

前几天一@同事看新浪微博里有个类似分隔线的提示,就自己试了几种方法来实现这个分隔线.下面就是简单实现分隔线的几种方法,个人比较喜欢第二种,我也给出了最后第五种比较2的写法,请大家拍砖,或者提供其他好的方法. 单个标签实现分隔线: 点此查看实例展示 .demo_line_01{ padding: 0 20px 0; margin: 20px 0; line-height: 1px; border-left: 200px solid #ddd; border-right: 200px solid #

关于Android LinearLayout添加分隔线的方法

目前了解的办法有两个:1.自定义一个view当作分隔线:2.使用高版本的分隔线属性 一.在需要添加分隔线的地方,添加一个view,比如ImageView,TextView等都可以,如代码,关键是设置高度要小,宽度要合适 <ImageView android:layout_width="fill_parent" android:layout_height="1dp" android:background="#00FF00" /> 二.就

CSS多种方法实现分隔线

<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8" /> <title>CSS实现分隔线的几种方法</title> <style> [url=home.php?mod=space&uid=597245]@charset[/url] "utf-8"; body,h1,h2,h3,h4,p,ul,li,ol,dl,dt,dd,i

bootstrap-下拉选项-下拉分隔线

1.运行效果如图所示 2.实现代码如下 <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <title>表单控件--下拉菜单(下拉分隔线)</title>     <!--

bootstrap-导航(垂直堆叠带分隔线的导航)

1.运行效果如图所示 2.实现代码如下 <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <title>导航(垂直堆叠带分隔线的导航)</title>     <!-- 最

css巧妙实现分隔线

单个标签实现分隔线 .demo_line_01{ padding: 0 20px 0; margin: 20px 0; line-height: 1px; border-left: 200px solid #ddd; border-right: 200px solid #ddd; text-align: center; } 优点:代码简洁 背景色实现分隔线 .demo_line_02{ height: 1px; border-top: 1px solid #ddd; text-align: ce

SWIFT中隐藏TableView多余的分隔线

在用TableView是如果数据不能填充满整个屏幕时,数据行下面会有空行及分隔线,这样不是很美观,如下 如何把多余的部分删除掉呢,其它很简单,把TableView的Footer替换为一个空的UIView即可. self.tableView.tableFooterView = UIView() so easy,It looks so nice

利用padding——实现高度可控的分隔线

一.实现分隔线的方法(未理解:不是说span元素垂直方向设置怕padding不影响吗?) html: 1 <div> 2 登陆<span></span>注册 3 </div> css: 1 .span{ 2 padding: 12px 6px 1px;/*这里通过改变第一个参数和第三个参数可以调节风隔线的的上下高度,分别是padding-top和padding-bottom*/ 3 margin-left:12px; 4 border-left:2px so