【发布时间】:2020-04-28 22:48:35
【问题描述】:
【问题讨论】:
-
这可能是一个没有文本的
RadioButton,旁边有两个TextView小部件。或者,您可以尝试在RadioButton文本中使用跨度和换行符来处理格式。使用 Android Studio 中的 Layout Inspector 查看该特定对话框正在使用什么。
标签: java android radio-button
【问题讨论】:
RadioButton,旁边有两个TextView 小部件。或者,您可以尝试在RadioButton 文本中使用跨度和换行符来处理格式。使用 Android Studio 中的 Layout Inspector 查看该特定对话框正在使用什么。
标签: java android radio-button
使用不带文字的RadioButton。对于文本使用TextView。检查
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:text="Phone Storage"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="/storage/emulated/0/Xender"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
输出:
【讨论】:
这可以通过使用带有两个 TextView 的 RadioButton 轻松完成,正如 CommonsWare 所提到的,但没有任何内置小部件。
这里是如何实现这一点的。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity">
<RadioButton
android:id="@+id/rbSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/rbSwitch"
android:text="Phone Storage"
android:textColor="@android:color/black"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvTitle"
android:layout_toRightOf="@id/rbSwitch"
android:text="/storage/emulated/0/Xender" />
</RelativeLayout>
【讨论】: