Android_day2

1.常用控件
Button, 
控件的宽高:(固定值 与两种状态)(宽和高是所有控件的基本属性)
android:layout_width="30dp"
android:layout_height="30dp"
match_parent (fill_parent)填充满父布局

wrap_content包裹内容

  1. 定义id: android:id=“@+id/linearLayout”

设置背景 : android:background=“”  
    颜色代码  #FFFFFF
    图片  @mipmap/aaa   
设置视图是否可见 : android:visibility=“gone”
    gone  完全消失
    visible 可见的 默认值
    invisible  消失 但是位置占据
重心引力(控制自己视图内部的 ) : android:gravity=“”  
    left
    right
    bottom
    top
    center
    center_vertical
    center_horizontal
重心位置 (控制自己视图相对于父布局的)android:layout_gravity=“” 
    left
    right
    bottom
    top
    center
    center_vertical
    center_horizontal
外边距
    四个方向 : android:layout_margin =“10dp”
    外左边距 : android:layout_marginLeft =“10dp” 
    外上边距 : android:layout_marginTop =“10dp” 
    外右边距 : android:layout_marginRight =“10dp” 
内边距
    四个方向 : android:layout_padding =“10dp”
    左内边距 : ndroid:paddingLeft= “10dp”
    上内边距 :  android:paddingTop= “10dp”
    右内边距 : android:paddingRight= “10dp”
    下内边距 : android:paddingButtom= “10dp”    外下边距 : android:layout_marginButtom =“10dp” 

text_view(其余和上面属性一样)
text 是其独有的属性
image(图片)
src 是image的独有属性

2.常用布局
线性布局,
指定方向 : (横向布局和纵向布局)    android:orientation=""
权重 :    android:layout_weight=""  (只能在线性布局重的子空间使用)

相对布局:   (注意: 要使用哪个就在哪个后面写TRUE)
相对父控件布局  相对兄弟控件布局
针对父控件   
android:layout_centerHorizontal      横向居中
android:layout_centerVertical          纵向居中
android:layout_centerInParent     横向纵向居中

跟父控件顶部/底部/最左边/最右边对齐
android:layout_alignParentTop        
android:layout_alignParentBottom                
android:layout_alignParentLeft            
android:layout_alignParentRight

针对已存在的兄弟控件(在某个控件的上面/下面/左边/右边)
android:layout_above    
android:layout_below                    
android:layout_toLeftOf                
android:layout_toRightOf

相对兄弟控件的边对齐            
android:layout_alignTop
android:layout_alignBottom
android:layout_alignLeft
android:layout_alignRight

TextView:
android:text="文本"
android:textSize="20sp"
android:textColor="#FF0"
android:textStyle="bold"
Typeface.BOLD //粗体
* Typeface.BOLD_ITALIC //粗斜体
* Typeface.ITALIC //斜体
* Typeface.NORMAL //常规

android:lines="3"
android:singleLine="true"
android:typeface="monospace" //设置字体
常用的字体类型名称还有:
* Typeface.DEFAULT //常规字体类型
* Typeface.DEFAULT_BOLD //黑体字体类型
* Typeface.MONOSPACE //等宽字体类型
* Typeface.SANS_SERIF //sans serif字体类型
* Typeface.SERIF //serif字体类型


帧布局、
网格布局
android:rowCount="6"
列数:android:columnCount="4"
跨列数:layout_columnSpan=“2”
跨行数:layout_rowSpan=“2”
列权重:layout_columnWeight=“1”
行权重:layout_rowWeight=“1”
表格布局、
常用属性:
(1)    collapseColumns=“0,2”:隐藏列,隐藏第一和第三列
(2)    stretchColumns=“1”:拉伸列
(3)    shrinkColumns=“1”:收缩列
<TableLayout />   表格标签
<TableRow />   表格行标签 该标签可以不使用

绝对布局
:绝对布局 控件在父控件中的绝对定位   (应用场景: 机顶盒开发 )
android:layout_x="30dp"
android:layout_y="30dp"

    帧布局
        什么是帧布局
            定义
                FrameLayout是按照层次堆叠在屏幕上的布局容器。
            内涵
                1.FrameLayout是最简单的布局了。
2.所有放在布局里的控件,都按照层次堆叠在屏幕的左上角。后加进来的控件覆盖前面的控件。
            外延
                HorizontalScrollView
                ScrollView
        帧布局的常用属性
            设置该帧布局容器的前景图像 : android:foreground="@drawable/red"
            设置前景图像显示的位置 : android:foregroundGravity="right|bottom"
    表格布局
        定义
            TableLayout是表格形式的布局容器。
        内涵
            TableLayout表格布局中,允许我们使用表格的方式来排列视图组件,使用行与列的方式来排列。因此,表格布局模型以行列的形式管理子控件。
4    网格布局行数:


        定义
            GridLayout是网格矩阵形式的布局容器。
        内涵
            1.GridLayout 是以矩形网格形式对容器的组件进行布置。
2,把容器按行列分成大小相等的矩形网格,一个网格中放置一个组件,组件宽高自动撑满网格。
    绝对布局
        定义
            AbsoluteLayout是所有子视图按照绝对位置进行摆放的布局容器。
        内涵
            1, AbsoluteLayout绝对布局需要指定子视图准确的x/y坐标值,并显示在屏幕上。
2,AbsoluteLayout绝对布局该布局没有屏幕边框,允许元素之间互相重叠。
        外延
            WebView


(1)    跑马灯
1、TextView调出跑马灯效果
android:singleLine="true"(设置出只显示一行)
android:ellipsize="marquee"(设置滚动)

2、TextView获取焦点

android:focusable="true"
android:focusableInTouchMode="true"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值