Java 如何在android RadioButton中添加标题和副标题?
我想知道如何在android的RadioButton中添加字幕。 如下图所示 带有字幕的单选按钮Java 如何在android RadioButton中添加标题和副标题?,java,android,radio-button,Java,Android,Radio Button,我想知道如何在android的RadioButton中添加字幕。 如下图所示 带有字幕的单选按钮 提前感谢…使用不带文本的单选按钮。对于文本使用TextView。检查 <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <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
。检查
<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>
输出:
如Commonware所述,使用带有两个文本视图的单选按钮可以轻松完成此操作,但没有任何内置小部件
以下是您如何实现这一目标的方法
<?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>
如Commonware所述,使用带有两个文本视图的单选按钮可以轻松完成此操作,但没有任何内置小部件
以下是您如何实现这一目标的方法
<?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>
这可能是一个没有文本的单选按钮,旁边有两个TextView
小部件。或者,您可以尝试使用单选按钮中的跨距和换行符来处理格式设置。使用Android Studio中的布局检查器查看特定对话框正在使用的内容。这可能是一个没有文本的单选按钮
,旁边有两个TextView
小部件。或者,您可以尝试使用单选按钮中的跨距和换行符来处理格式设置。使用Android Studio中的布局检查器查看特定对话框正在使用的内容。