代码之家  ›  专栏  ›  技术社区  ›  Kai

在Android中创建一个空的抽屉

  •  38
  • Kai  · 技术社区  · 15 年前

    创建一个完全空的可绘制文件似乎是一个常见的需求,比如作为一个位置持有者、初始状态等,但是似乎没有一个好的方法来实现这一点……至少在XML中。有几个地方是指系统资源 @android:drawable/empty 但据我所知(也就是说,它不在参考文档中,AAPT扼流圈说它找不到资源),这是不存在的。

    有没有一种引用空的可绘制文件的一般方法,或者最终为每个项目创建一个假的空PNG?

    7 回复  |  直到 6 年前
        1
  •  94
  •   Pi Delport    12 年前

    @android:id/empty @android:color/transparent

        2
  •  9
  •   JulianSymes    11 年前

    ShapeDrawable <shape/>

        3
  •  5
  •   Hans    10 年前
    <shape />
    

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" />
    

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_enabled="true">
            <shape android:shape="oval">
                <size android:height="10dp" android:width="10dp" />
                <solid android:color="@android:color/white" />
            </shape>
        </item>
        <item android:state_enabled="false">
            <shape />
        </item>
    </selector> 
    
        4
  •  3
  •   wirbly    14 年前

        5
  •  3
  •   laalto    11 年前

    @null null Drawable

        6
  •  3
  •   Andrey Timofeev    6 年前

    @android:color/transparent android:constantSize="true" <selector>

        7
  •  2
  •   John LeBoeuf-Little    15 年前