Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在android RadioButton中添加标题和副标题?_Java_Android_Radio Button - Fatal编程技术网

Java 如何在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

我想知道如何在android的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中的布局检查器查看特定对话框正在使用的内容。