android - Android Studio 在 XML 中将 Switch 添加到 textview 的左侧
问题描述
与使用 向 textview 左侧添加图标类似android:drawableleft="..."
,我想做类似的事情,除了switch
在同一个 XML 文件中使用预定义的。我该怎么做?
解决方案
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/switch" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Switch Text" />
</LinearLayout>
如果是单选按钮或复选框,您总是可以使用类似这样的东西
android:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
推荐阅读
- php - 检查 JSON 是否有 Given Key
- python - Python-我的数据集包含日期时间列,它不允许我进行任何处理
- c# - 如何从存储过程中提取数据并动态创建 zip 文件夹并添加 csv 文件
- swift - Apple 应用内配置(将卡添加到钱包)
- flutter - 我可以创建 Get.find<>() 的单个实例吗?
- java - Flink 去重和 processWindowFunction
- datatable - 成功时数据表复制标题
- vue.js - Nuxt 手表不重定向
- javascript - 将 Loader 放入数据网格打字稿中
- python - 如何从 Scrapy Selector 中删除子元素?