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>

正常状态:     点击:

时间: 2024-08-27 00:45:14

xml布局内容总结(三)--Android的相关文章

xml布局内容总结(二)--Android

关于xml中margin和padding的内容,在刚接触xml的时候会有些混淆和模糊,在此进行总结,希望能帮助到有需要的人. 2.xml中margin和padding <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width

xml布局内容总结(四)--Android

(1)对于xml编写界面较复杂的情况下,使用include会使得编写和查看更清楚 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <include android:id="@+id/hi1" layout="@

android :点击某个按钮弹出在原有布局中没有(或者存在)内容 :以删除原有布局内容为例

主要涉及了(1)对布局中某个控件的监听 (2)在布局文件中设置可显示,删除的参数 visibility的参数的有三个,在这里我只设置了一个,可见的. android:visibility="visible" 剩下的和他的用法相同. (3)在代码中监听控件后,对visibility的参数重新设置. 效果图:点击按钮后edittext不见了 (1)点击高级按钮前 (2)点击高级按钮后 (1)布局文件 <?xml version="1.0" encoding=&qu

Android中measure过程、WRAP_CONTENT详解以及xml布局文件解析流程浅析(上

                                                                                                                                               本文原创, 转载请注明出处:http://blog.csdn.net/qinjuning 在之前一篇博文中<<Android中View绘制流程以及invalidate()等相关方法分析>>,简单的阐述

Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析

转自:http://www.uml.org.cn/mobiledev/201211221.asp 今天,我着重讲解下如下三个内容: measure过程 WRAP_CONTENT.MATCH_PARENT/FILL_PARENT属性的原理说明 xml布局文件解析成View树的流程分析. 希望对大家能有帮助.- - 分析版本基于Android 2.3 . 1.WRAP_CONTENT.MATCH_PARENT/FILL_PARENT 初入Android殿堂的同学们,对这三个属性一定又爱又恨.爱的是使

Android中点击按钮获取string.xml中内容并弹窗提示

场景 AndroidStudio跑起来第一个App时新手遇到的那些坑: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103797243 效果 注: 博客:https://blog.csdn.net/badao_liumang_qizhi关注公众号霸道的程序猿获取编程相关电子书.教程推送与免费下载. 实现 新建project后,打开布局文件activity_main.xml 添加一个Button <Button android

Android——ListView布局+适配器(三)

Android--ListView布局+适配器(三) package com.example.administrator.newstop; import android.os.Bundle; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import andro

Android中将xml布局文件转化为View树的过程分析(下)-- LayoutInflater源码分析

在Android开发中为了inflate一个布局文件,大体有2种方式,如下所示: // 1. get a instance of LayoutInflater, then do whatever you want LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // 2. you're in some View class, then jus

android XML布局大全

第一类:属性值为true或falseandroid:layout_centerHrizontal  水平居中android:layout_centerVertical   垂直居中android:layout_centerInparent    相对于父元素完全居中android:layout_alignParentBottom 贴紧父元素的下边缘android:layout_alignParentLeft   贴紧父元素的左边缘android:layout_alignParentRight