栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

基础控件2

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基础控件2

Notification

 

                 

1.NotificationManager是一个通知管理器类,这个对象是由系统维护的服务,是以单例模式的方式获得,一般并不实例化这个对象。在Activity中,可以使用Activity.getSystemService(String)方法获取

2.NotificationChannel

 3.Notification常用属性

.setContentTifle(String string)设置标题

.setContentText(String string)设置文本内容

.setSmallicon(int icon)设置小图标

.setLargeIcon(Bitmap icon)设置通知的大图标

.setColor(int argb)设置小图标的颜色

.serContentIntent(PendingIntent intent)设置点击通知后的跳转意图

.setAutoCancel(boolean boolean)设置点击通知后自动清除通知

.setWhen(long when)设置通知被创建的时间


Toolbar

1.要用Toolbar需要在values/themes中将DarkActionBar改成NoActionBar

一.常用属性

1、android:layout_width=""

2、android:layout_height="?attr/actionBarSize"

3、android:background=""

4、android:navigationIcon="@"

5、app:title="主标题"

6、app:titleTextColor=""

7、app:titleMarginStart=""

8、app:subtitle="子标题"

9、app:subtitleTextColor=""

10、app:logo="@"


alertDialog

首先创建alertDialog的构造器 new alertDialog(context:this)

一、属性

1.setIcon()添加图标

2.setTitle()添加标题

3.setMessage()添加消息

4.setView()设置自定义布局

5.create()创建Dialog

6.show()显示对话框

7.setPositiveButton 确定按钮   new DialogInterface.onClickListener()

8.setNegativeButton  取消按钮

9.setNeutralButton  中间按钮


PopupWindow

1. setContentView(View contentView); 设置PopupWindow显示的view

2. showAsDropDown(View anchor); 相对某个控件的位置(左下),无偏移

3. showAsDropDpwn(View anchor,int xoff,int yoff); 相对某个控件的位置有偏移

4. setFocusable(boolean focusable) 设置是否获取焦点

5. setbackgroundDrawable(Drawable background)设置背景

6. dismiss() 关闭弹窗

7. setAnimationStyle(int animationStyle)设置加载动画

8. setTouchable(boolean touchable) 设置触摸功能

9. setOutsideTouchable(boolean touchable) 设置popupWindow外面的触摸功能


布局 LinearLayout

一,属性

1.orientation 布局中组件的排列方式

2.gravity 控件组件所包含的子元素的对齐方式,可多个组合

3.layout_gravity控制该组件在父容器里的对齐方式

4.background 背景图片或颜色

5.divider 分割线

6.showDividers 设置分割线所在的位置,none(无),beginning(开始),end(结束),middle(每两个组件间)

7.dividerpadding 设置分割线的padding

8.layout_weight(权重)该属性等比例划分去域


RelativeLayout

一,根据父容器定位

1.layout_alignParentLeft左对齐

2.layout_alignParentRight 右对齐

3.layout_alignParentTop 顶部对齐

4.layout_alignParentBottom 底部对齐

5.layout_centerHorizontal 水平居中

6.layout_centerVertical 垂直居中

7.layout_centerInParent 中间居中

二,根据兄弟组件定位

1.layout_toLeftOf 放置于参数组件的左边

2.layout_toRightOf 放置于参数组件的右边

3.layout_above 放置于参数组件的上方

4.layout_below 放置于参数组件的下方

5.layout_alignTop 对齐参数组件的上边界

6.layout_alignbutton 对齐参数组件的下边界

7.layout_alignLeft 对齐参数组件的左边界

8.layout_alignRight 对齐参数组件的右边界


frameLayout

1.android:foreground 设置前景

2.android:foregroundGravity 设置前景位置


TableLayout 表格布局

1. 会将里面的组件放在一行里,超出不显示

2.android:collapseColumns 设置需要被隐藏的列的序号

3,android:stretchColumns 设置允许被拉伸的序列号,从0开始

4.android:shrinkColumns 设置允许被收缩的列的序号,从0开始

子控件设置属性

1.android:layout_column 显示在第几列

2.android:layout_span 横向跨几列


GridLayout 网格布局

一,常见属性

1.android:orientation  设置水平显示还是垂直显示

2.android:columnCount 设置行的显示个数

3.android:rowCount 设置列的显示个数

二,子控件属性

1.android:layout_column 显示在第几列

2.android:layout_columnSpan 横向跨几列

3.android:layout_columnWeight 横向剩余空间分配方式

4.android:layout_gravity 在网络中的显示位置

5.android:layout_row 显示在第几行

6.android:layout_rowSpan 横向跨几行

7.android:layout_rowWeight 纵向剩余空间分配方式


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/644105.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号