代码之家  ›  专栏  ›  技术社区  ›  Code Lover

Android:文档上有没有特定的地方可以找到显式XML引用?

  •  0
  • Code Lover  · 技术社区  · 7 年前

    Android的XML文档很难找到。我得到的都是与Java相关的文档。我是Android的新手,正在尝试为视图和小部件寻找XML引用。现在,我在寻找 Checkbox 但我很难每次为任何组件获取XML引用。

    有谁能帮助我学习如何查找和使用参考文档,特别是XML及其属性?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Samantha    7 年前

    enter image description here

    复选框是通过继承CompoundButton、TextView等创建的。 每个视图都有自己的XML属性。因此,对于CheckBox,所有继承的值都是适用的。例如,ChackBox有按钮行为、文本框行为等,因此以上所有内容都适用于该复选框。因此,如果您想添加复选框的按钮相关行为,请参阅上面的“按钮属性”。如果要添加复选框的文本相关行为,请参阅上面的“文本视图属性”等。

    另请参阅 https://developer.android.com/reference/android/R.styleable

    布局xml示例如下:;

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:orientation="vertical">
        <LinearLayout android:id="@+id/llMainFill"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="bottom"
                    android:orientation="vertical">
        <ListView android:id="@+id/lvLog"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:visibility="invisible" />
      </LinearLayout>
    </LinearLayout>