近段时间的学习碎片整理(1)

@SerializedName

        value:填的是对应json数据上的字段名(序列化)

        alternate:Java model类转为json时,这个字段对应json上面的哪个字段用这个(反序列化)

Android流行UI布局——底部导航

参考:Android流行UI布局——底部导航(BottomNavigationView+ViewPager+Fragment) - 简书

        1、导包

        2、在res下的Menu文件夹中创建menu菜单

        3、布局文件,viewpager标签和buttomNavigationView标签(View标签可以做背景效果)

        4、Fragment文件

        5、添加监听事件,实现ViewPager的适配器

                bottomNavigationView.setOnNavigationItemSelectedListener

                viewPager.addOnPageChangeListener

        6、通过适配器将Fragment添加到Viewpager中

约束布局(ConstraintLayout)

参考:约束布局ConstraintLayout使用详解 - 简书

1、常用属性:

layout_constraintLeft_toLeftOf
layout_constraintLeft_toRightOf
layout_constraintRight_toLeftOf
layout_constraintRight_toRightOf
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf
layout_constraintBaseline_toBaselineOf
layout_constraintStart_toEndOf
layout_constraintStart_toStartOf
layout_constraintEnd_toStartOf
layout_constraintEnd_toEndOf

  其中左右一般用start和end这两个

2、官方在约束布局中不推荐使用match_parent,推荐使用0dp配合约束代替

3、链条

        layout_constraintHorizontal_chainStyle和 layout_constraintVertical_chainStyle

        spread,spread_inside,packed 三种样式

Field

         1、为我们提供了获取当前对象的成员变量的类型,和重新设值的方法   

         2、getType()方法返回的是Class<?>类型的,而getGenericType()返回的是Type类型的

         3、getDeclaredField("想要获得的变量名"),但仅能获取类本身的属性成员(包括私有、共有、保护)

         4、setAccessible(true)  在Java中可以通过反射进行获取实体类中的字段值,当未设置Field的setAccessible方法为true时,会在调用的时候进行访问安全检查,会抛出IllegalAccessException异常    

                

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值