カスタムRadioButtonを拡張して作成する以外の方法で、RadioGroupのRadioButtonの下にTextViewを追加することはできますか?RadioGroupのTextViewを持つRadioButton
7
A
答えて
5
はい、その可能。以下を参照してください:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn1" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sample text" />
</RadioGroup>
</LinearLayout>
サンプル出力:
0
XMLからRadioGroupを削除し、ラジオボタンを1つずつ追加できます。この時 ルック:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioGroup1"
android:text="RadioButton" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioButton1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:text="RadioButton" />
</RelativeLayout>
+0
を考えるDNTが、私はグループと同様のRadioButtonでは動作しないことができ、その後 - 独自のRadioButton機構をコーディングの多くが含まれ... – Michal
0
私はあなたが別のトリッキーなソリューションを使用することができると思います。パディングまたはマージンを使用して2つのラジオボタンの間にギャップを作成し、ギャップにtextViewを配置します。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="78dp" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="RadioButton"
android:layout_marginBottom="100dp"/>
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton"
android:layout_marginBottom="100dp"/>
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioGroup1"
android:layout_centerHorizontal="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true"
android:layout_marginTop="200dp"/>
</RelativeLayout>
+0
、働いていない、center_horizontalを削除しよう...画面の上にそれ自身を整列... – Michal
関連する問題
- 1. radioGroupにradioButtonとtextViewを揃える方法は?
- 2. ConstraintLayout、RadioGroup、RadioButtonの2列
- 3. AndroidのRadioGroupでRadioButtonの配列を取得します
- 4. RadioButtonを内部に持つRadioGroupを動的に作成することはできますか(w/o xml)?
- 5. AlertDialog内のRadioGroup:単一のRadioButtonが表示されます
- 6. RadioGroup内のLineaLayoutにあるRadioButtonの配置方法
- 7. 左のTextViewと右のRadioButtonのLinearLayout?
- 8. RadioButtonでレイアウトを拡張し、RadioGroupに追加する方法は?
- 9. RadioGroupから選択したRadioButtonをキャプチャします
- 10. 2つのTextViewを持つカスタムビュー
- 11. Android:特定のRadioButtonはどのRadioGroupに属していますか?
- 12. 編集の可能性を持つTextViewへのリンクTextView(Swift 4)
- 13. アンドロイド - 私はこのコードでカスタムのTextViewクラスを持つカスタムのTextView
- 14. RadioGroupの選択されたRadioButton状態は、フラグメントを使用するSharedPreferencesに保存されます。
- 15. Android RadioGroup
- 16. android.content.res.Resources RadioGroupの$ NotFoundException
- 17. 使用のRadioButtonは、一つの活性
- 18. RadioGroup checkedButtonプロパティ
- 19. Python Bokeh CustomJS RadioGroup
- 20. Android RadioGroupラジオボタンJava
- 21. のTextView「fill_parent」私はシンプルなレイアウトを持つ親
- 22. は、私はラジオボタンのリストを持っているのRadioButton
- 23. アンドロイド - とのRadioButton
- 24. ExpandableListビューのRadioButton
- 25. MVCのRadioButton
- 26. RadioButtonのカスタムレイアウト
- 27. QMLデスクトップのRadioButton
- 28. リストビューonClickListener()のRadioButton
- 29. RecyclerView内のRadioButton
- 30. ExtJs set RadioGroupモデル別
私は、はい...そう –