Как добавить заголовок и субтитры в android RadioButton? - PullRequest
0 голосов
/ 11 января 2020

Я хочу знать, как добавить субтитры в RadioButton в android. Как на рисунке ниже.

Радиокнопка с субтитрами
enter image description here

Заранее спасибо ...

Ответы [ 2 ]

0 голосов
/ 11 января 2020

Это можно легко сделать, используя A RadioButton с двумя TextView , как упомянуто 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>

enter image description here

0 голосов
/ 11 января 2020

Используйте 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>

Вывод:

enter image description here

...