• xml布局内容总结(三)--Android


    关于xml中经经常使用到边框及边框效果,在此进行一下总结。

    3.border(边框及边框效果)

    (1)直角边框线



    <LinearLayout
            android:layout_width="200dp"
            android:layout_height="30dp"
            android:layout_margin="10dp"
            android:orientation="vertical" 
            android:background="@drawable/border_c"
            >
        </LinearLayout>

    border_c.xml

    <?

    xml version="1.0" encoding="utf-8"?

    >  
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >  
      <!-- 填充颜色 -->
        <solid android:color="@color/listitem_green" />  
      <!-- 边框宽度。颜色 -->
        <stroke  
            android:width="0.1dp"  
            android:color="@color/black" />
        <!-- 4个角度的弧度设置 -->  
      <corners 
          android:topLeftRadius="0.0dip" 
          android:topRightRadius="0.0dip" 
          android:bottomLeftRadius="0.0dip" 
          android:bottomRightRadius="0.0dip" 
          />  
    </shape> 

    (2)圆角边框线



    <LinearLayout
            android:layout_width="200dp"
            android:layout_height="30dp"
            android:layout_margin="10dp"
            android:orientation="vertical" 
            android:background="@drawable/border_s"
            >
        </LinearLayout>

    border_s.xml

    <?xml version="1.0" encoding="utf-8"?>  
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >  
      <!-- 填充颜色 -->
        <solid android:color="@color/yellow" />  
      <!-- 边框宽度,颜色 -->
        <stroke  
            android:width="0.1dp"  
            android:color="@color/black" />
        <!-- 4个角度的弧度设置 -->  
      <corners 
          android:topLeftRadius="10.0dip" 
          android:topRightRadius="10.0dip" 
          android:bottomLeftRadius="10.0dip" 
          android:bottomRightRadius="10.0dip" 
          />  
    </shape> 

    (3)横线,竖线



    <TextView
            android:layout_width="200dp"
            android:layout_height="0.5dp"
            android:background="@color/black"
             />
        <TextView
            android:layout_marginTop="10dp"
            android:layout_width="0.5dp"
            android:layout_height="50dp"
            android:background="@color/black"
             />

    (4)button效果

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:background="@drawable/btn_style_green"
            android:text="Button" 
            android:textColor="@color/white"
            />

    btn_style_green.xml

    <?xml version="1.0" encoding="utf-8"?>  
    <selector xmlns:android="http://schemas.android.com/apk/res/android">  
      
        <item android:drawable="@drawable/button_green_bg" android:state_pressed="true"/>  
        <item android:drawable="@drawable/button_blue_bg" android:state_focused="false" android:state_pressed="false"/>     
      
    </selector>

    button_green_bg.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape
      xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="@color/green" />
        <stroke android:width="0.5dip" android:color="@color/black" />
        <corners android:topLeftRadius="5.0dip" android:topRightRadius="5.0dip" android:bottomLeftRadius="5.0dip" android:bottomRightRadius="5.0dip" />
    </shape>


    button_blue_bg.xml

    <?

    xml version="1.0" encoding="utf-8"?>
    <shape
      xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="@color/blue" />
        <stroke android:width="0.5dip" android:color="@color/black" />
        <corners android:topLeftRadius="5.0dip" android:topRightRadius="5.0dip" android:bottomLeftRadius="5.0dip" android:bottomRightRadius="5.0dip" />
    </shape>


    正常状态:     点击:



  • 相关阅读:
    BZOJ 1266: [AHOI2006]上学路线route
    重磅!阿里云Promtheus 正式免费公测
    解锁云原生 AI 技能|在 Kubernetes 上构建机器学习系统
    更新与发展 | Alibaba Cloud Linux 2 特性与开发细节揭秘
    《2019上半年DDoS攻击态势报告》发布:应用层攻击形势依然严峻,海量移动设备成新一代肉鸡
    《2019年上半年Web应用安全报告》发布:90%以上攻击流量来源于扫描器,IP身份不再可信
    并发模式与 RPS 模式之争,性能压测领域的星球大战
    互联网商城的上云改造之旅
    技术人具备“结构化思维”意味着什么?
    弘康人寿基于 RocketMQ 构建微服务边界总线的实践
  • 原文地址:https://www.cnblogs.com/lytwajue/p/6760862.html
Copyright © 2020-2023  润新知