有没有办法避免在自定义视图(Android)中使用xml中的完整包名?

loe*_*chg 6 xml android

我想做点什么

<TextViewPlus
    android:id="@+id/settings_title_text"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:text="@string/settings />
Run Code Online (Sandbox Code Playgroud)

代替

<com.my.really.super.long.package.name.that.wont.autocomplete.TextViewPlus
    android:id="@+id/settings_title_text"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:text="@string/settings />
Run Code Online (Sandbox Code Playgroud)

我想我可以把自定义视图放在(默认)包中,但这似乎是一个坏主意.(编辑:经过测试,它无论如何都不起作用)是否有"好"的方法来做到这一点?

Vin*_*rat 3

不,据我所知,您必须使用全名。

  • 您将获得的唯一快捷方式是如果您想使用 xmlns:custom (http://developer.android.com/training/custom-views/create-view.html) 缩短自定义属性的命名空间 (3认同)