Darkmisc
- 222
- 31
- TL;DR Summary
- I'd like to set an ImageView as the background for radio buttons. It only works if I hardcode the width and height of the ImageView. If I set the height and width to "match_parent", the ImageView is visible, but not the radio buttons.
Hi everyone
I'd like to set an ImageView background for a menu screen that uses ScrollView, ConstrainedLayout and Radio Buttons. This is possible if I hardcode the width and height of the ImageView, but I don't want to do this because it might ruin the formatting on some models of phone.
I'd like to set the dimensions to "match_parent" or "wrap_content", but if I do this, only the ImageView is visible. The Radio Buttons aren't visible at all.
Is there a way around this? I've tried putting the code for the ImageView inside the Radio Group, and it doesn't help.
My xml code for the menu is below.
Thanks
[CODE lang="java" title="menu"]<?xml version="1.0" encoding="utf-8"?><ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight = "1"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp"
android:fillViewport="true"> <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".Menu">
<ImageView
android:id="@+id/imageView1"
android:layout_width="400dp"
android:layout_height="400dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:scaleType="centerCrop"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:src="@drawable/cherry"/> <TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:text="Choose characters" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<CheckBox
android:id="@+id/a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ア a イ i ウ u エ e オ o" />
<CheckBox
android:id="@+id/k"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="カ ka キ ki ク ku ケ ke コ ko キャ kya キュ kyu キョ kyo
" />
<CheckBox
android:id="@+id/s"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="サ sa シ shi ス su セ se ソ so シャ sha シュ shu ショ sho
" />
<CheckBox
android:id="@+id/ta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="タ ta チ chi ツ tsu テ te ト to チャ cha チュ chu チョ cho" />
<CheckBox
android:id="@+id/na"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ナ na ニ ni ヌ nu ネ ne ノ no ニャ nya ニュ nyu ニョ nyo" />
<CheckBox
android:id="@+id/h"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ハ ha ヒ hi フ fu ヘ he ホ ho ヒャ hya ヒュ hyu ヒョ hyo" />
<CheckBox
android:id="@+id/m"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="マ ma ミ mi ム mu メ me モ mo ミャ mya ミュ myu ミョ myo" />
<CheckBox
android:id="@+id/y"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ヤ ya ユ yu ヨ yo" />
<CheckBox
android:id="@+id/r"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ラ ra リ ri ル ru レ re ロ ro リャ rya リュ ryu リョ ryo" />
<CheckBox
android:id="@+id/wa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ワ wa" />
<CheckBox
android:id="@+id/n"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ン n" /> <CheckBox
android:id="@+id/g"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ガ ga ギ gi グ gu ゲ ge ゴ go ギャ gya ギュ guy ギョ gyo" />
<CheckBox
android:id="@+id/z"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ザ za ジ ji ズ zu ゼ ze ゾ zo ジャ ja ジュ ju ジョ jo" />
<CheckBox
android:id="@+id/d"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ダ da ヂ (ji) ヅ (zu) デ de ド do" />
<CheckBox
android:id="@+id/b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="バ ba ビ bi ブ bu ベ be ボ bo ビャ bya ビュ byu ビョ byo" />
<CheckBox
android:id="@+id/p"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="パ pa ピ pi プ pu ペ pe ポ po ピャ pya ピュ pyu ピョ pyo" />
<CheckBox
android:id="@+id/f"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ファ fa フィ fi フェ fe フォ fo" />
<CheckBox
android:id="@+id/t"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ツァ tsa ティ ti トゥ tu" />
<CheckBox
android:id="@+id/w"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ウェ we ウォ wo" />
<CheckBox
android:id="@+id/all"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="all" /> </RadioGroup>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="Button"
android
nClick="onClick"
tools:layout_editor_absoluteX="18dp"
tools:layout_editor_absoluteY="582dp" /> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
[/CODE]
I'd like to set an ImageView background for a menu screen that uses ScrollView, ConstrainedLayout and Radio Buttons. This is possible if I hardcode the width and height of the ImageView, but I don't want to do this because it might ruin the formatting on some models of phone.
I'd like to set the dimensions to "match_parent" or "wrap_content", but if I do this, only the ImageView is visible. The Radio Buttons aren't visible at all.
Is there a way around this? I've tried putting the code for the ImageView inside the Radio Group, and it doesn't help.
My xml code for the menu is below.
Thanks
[CODE lang="java" title="menu"]<?xml version="1.0" encoding="utf-8"?><ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight = "1"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp"
android:fillViewport="true"> <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".Menu">
<ImageView
android:id="@+id/imageView1"
android:layout_width="400dp"
android:layout_height="400dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:scaleType="centerCrop"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:src="@drawable/cherry"/> <TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:text="Choose characters" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<CheckBox
android:id="@+id/a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ア a イ i ウ u エ e オ o" />
<CheckBox
android:id="@+id/k"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="カ ka キ ki ク ku ケ ke コ ko キャ kya キュ kyu キョ kyo
" />
<CheckBox
android:id="@+id/s"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="サ sa シ shi ス su セ se ソ so シャ sha シュ shu ショ sho
" />
<CheckBox
android:id="@+id/ta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="タ ta チ chi ツ tsu テ te ト to チャ cha チュ chu チョ cho" />
<CheckBox
android:id="@+id/na"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ナ na ニ ni ヌ nu ネ ne ノ no ニャ nya ニュ nyu ニョ nyo" />
<CheckBox
android:id="@+id/h"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ハ ha ヒ hi フ fu ヘ he ホ ho ヒャ hya ヒュ hyu ヒョ hyo" />
<CheckBox
android:id="@+id/m"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="マ ma ミ mi ム mu メ me モ mo ミャ mya ミュ myu ミョ myo" />
<CheckBox
android:id="@+id/y"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ヤ ya ユ yu ヨ yo" />
<CheckBox
android:id="@+id/r"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ラ ra リ ri ル ru レ re ロ ro リャ rya リュ ryu リョ ryo" />
<CheckBox
android:id="@+id/wa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ワ wa" />
<CheckBox
android:id="@+id/n"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ン n" /> <CheckBox
android:id="@+id/g"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ガ ga ギ gi グ gu ゲ ge ゴ go ギャ gya ギュ guy ギョ gyo" />
<CheckBox
android:id="@+id/z"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ザ za ジ ji ズ zu ゼ ze ゾ zo ジャ ja ジュ ju ジョ jo" />
<CheckBox
android:id="@+id/d"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ダ da ヂ (ji) ヅ (zu) デ de ド do" />
<CheckBox
android:id="@+id/b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="バ ba ビ bi ブ bu ベ be ボ bo ビャ bya ビュ byu ビョ byo" />
<CheckBox
android:id="@+id/p"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="パ pa ピ pi プ pu ペ pe ポ po ピャ pya ピュ pyu ピョ pyo" />
<CheckBox
android:id="@+id/f"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ファ fa フィ fi フェ fe フォ fo" />
<CheckBox
android:id="@+id/t"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ツァ tsa ティ ti トゥ tu" />
<CheckBox
android:id="@+id/w"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ウェ we ウォ wo" />
<CheckBox
android:id="@+id/all"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="all" /> </RadioGroup>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="Button"
android

tools:layout_editor_absoluteX="18dp"
tools:layout_editor_absoluteY="582dp" /> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
[/CODE]