【Android-View】Android View控相关低频属性

目录

1. TextView

2. EditText

3. ImageView

4. Button

4.1 去掉Button默认的点击阴影

5. CheckBox

5.1 调整原生样式CheckBox的大小

5.2 调整原生样式CheckBox的颜色

6. RecyclerView

7. Toolbar

8. CardView

8.1 CardView去除阴影


1. TextView

 

2. EditText

 

3. ImageView

 

4. Button

4.1 去掉Button默认的点击阴影

控件添加属性

style="?android:attr/borderlessButtonStyle"

 

5. CheckBox

5.1 调整原生样式CheckBox的大小

【问题】即便设置layout_width和layout_height为wrap_content的时候发现他还是很大。
【方案】可使用【scaleX/Y】属性:

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content
    android:scaleX="0.6"
    android:scaleY="0.6"/>

【参考】https://blog.csdn.net/lintcgirl/article/details/48312309

 

5.2 调整原生样式CheckBox的颜色

【问题】原生样式的CheckBox带有点选动画,选中为绿色,未选中为灰色,且自带点击波纹效果。但如要修改点选颜色,却发现源码中使用的是图片而非色值。
【方案】自定义样式,并引用。

① 在[module>src>main>res>values>styles.xml]文件中,自定义样式。
其中“colorControlNormal”为未选中时的颜色,“colorControlActivated”为选中之后的颜色,色值可自定义:

    <style name="InfoCheckBox" parent="Theme.AppCompat.Light">
        <item name="colorControlNormal">@color/colorGray</item>
        <item name="colorControlActivated">@color/colorRed</item>
    </style>

② 在CheckBox控件中使用该自定义样式,注意,使用【android:theme】属性,而非“style

<CheckBox
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:theme="@style/MyCheckBox" />

【参考】https://blog.csdn.net/ulddfhv/article/details/83047055

 

6. RecyclerView

7. Toolbar

8. CardView

8.1 CardView去除阴影

控件添加CardView属性:

app:cardElevation="0dp"

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值