ylcx123
V2EX  ›  Android

怎么求 Android 的 checkbox 中正方形选框中心距离左边距的偏移距离?

  •  
  •   ylcx123 · Oct 26, 2015 · 14068 views
    This topic created in 3877 days ago, the information mentioned may be changed or developed.
    想做个提示,提示这个 checkbox 已经被框选上了,需要把提示箭头指向正方形。目前无法解决正方形选框中心到左边距的偏移,求办法。

    这个功能类似 QQ 购买包月服务时的 自动续费提示
    8 replies    2015-10-31 13:52:47 +08:00
    Vo7ice
        1
    Vo7ice  
       Oct 26, 2015
    做个 selector 不会更快吗?
    ylcx123
        2
    ylcx123  
    OP
       Oct 26, 2015
    @Vo7ice 没懂,先解决怎么求偏移距离, 这个提示与 selector 有什么关系?
    sortbylist
        3
    sortbylist  
       Oct 27, 2015
    @ylcx123 应该说的是给 checkbox 加背景 selector 吧。如果选中了,就背景设置带箭头的图片。
    zhgg0
        4
    zhgg0  
       Oct 27, 2015
    选框自定义,不要用默认的,就有办法计算
    ylcx123
        5
    ylcx123  
    OP
       Oct 30, 2015
    @zhgg0 自定义的这么计算?
    zhgg0
        6
    zhgg0  
       Oct 31, 2015
    @ylcx123 知道选框高,就知道中心点到左边的偏移了
    ylcx123
        7
    ylcx123  
    OP
       Oct 31, 2015
    @zhgg0 选框图片 中正方形选框周围有 padding 距离呀,你这样,也求不出来
    zhgg0
        8
    zhgg0  
       Oct 31, 2015
    @ylcx123 左边的选框用 drawableLeft ,不用默认的, drawable 的宽高不是可以求出来吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5374 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 03:51 · PVG 11:51 · LAX 20:51 · JFK 23:51
    ♥ Do have faith in what you're doing.