android开发常用设置

1.修改EditText的光标颜色

    android:textCursorDrawable = "颜色";

    在drawable文件夹中添加edit_cursor_color.xml。

<shape>
    <size android:width="1dp"/>
    <solid android:color="#000"/>
</shape>

2.修改dialog的按钮颜色

dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.BLACK);
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(Color.BLACK);

3.修改TextView的透明度

textView.getBackground().setAlpha(100);   //0~255

4.输入法弹出导致布局上移的解决办法

    在AndroidMainfest文件中给activity添加属性

android:windowSoftInputMode="adjustPan"

5.修改ProgressBar的颜色

android:indeterminateTint="#ccc"

6.将某个控件附在按钮上方,并能显示该控件不被按钮遮挡

android:stateListAnimator = "@null"

    从5.0开始,在同一个Layout下,Button将总是位于最上层,点击时默认有阴影效果表示按下的状态,5.0以前只是变色。上方的代码则去掉阴影效果,使Button可以被正常覆盖。

7.设置渐变色

<shape>
    <gradient android:startColor=""
        angle="0" //0.从左到右渐变 90.从下到上 180.从上到下 270.从右到左
    />
</shape>

8.设置CheckBox选中的颜色

android:theme="@style/MyCheckBox"

<style name="myCheckBox" parent="@android:style/widget.Material.CompoundButton.CheckBox" tools:targetApi="lollipop">
    <item name="android:colorControlActivated">@color/...</item>
    <item name="android:colorControlNormal">@coloc/...</item>
</style>

9.防止点击多个控件

android:splitMotionEvents="false"

10.解决APP启动时白屏的问题

    在style.xml中新建一个StyleTheme,设置windowBackground的颜色或背景图片,欢迎页的theme="@style/StyleTheme"。

    

11.给布局设置圆角

    在drawable中创建linearLayout_border_radius_.xml。

<shape>
    <solid android:color="xxx"/>    //背景的颜色
    <corners android:topLeftRadius="xxpx" //左上角的角度
             android:topRightRadius=""    //右上角
             android:bottomRightRadius=""    //右下角
             android:bottomLeftRadius=""    //左下角
</shape>

12.隐藏EditText的下划线

background = "@null"

13.给按钮设置圆角边框

<corner android:radius="xxxdip"/>

14.设置边框线的宽度和颜色

<stroke android:width="" android:color=""/>

15.设置点击更换按压图片

<selector>
    <item android:state_pressed="true" android:drawable="按压后显示的图片"/>
    <item android:state_checked="true" android:drawable=""/>
    <item android:state_selected="true" android:drawable=""/>
    <item android:drawable="正常图片"/>
</selector>

16.不允许EditText换行

inputType="text"
maxLines="1"
lines="1"
singleLine="true"

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值