Android radio button text truncated - android

I have an app that shows a Radio Group with four Radio Buttons whose test is set dynamically. I am no able to get the whole text on a single line.
It gets wrapped on two lines, or truncated at the end. It seems like there is a vertical edge, and text cannot go over it.
My layout is
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="vds.quizmanager.QuizManagerActivity" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="41dp"
android:text="Domanda:" />
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="19dp" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:layout_marginTop="24dp"
android:layout_toLeftOf="#+id/button2" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minWidth="#dimen/activity_vertical_margin" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radio3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RadioGroup>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup1"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:text="Domanda" />
</RelativeLayout>

OK then you can try this code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="41dp"
android:text="Domanda:" />
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="19dp"
android:text="sdfsgdshfdgsasRFAGRESTDGHFSAFAWhtjygukjtyhergwrqTQETWRYJETRHEWRQEJTUKRYJTRHEAWRWetjyurrutjretwrtjyeukyriu" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="24dp"
android:layout_toLeftOf="#+id/button2" >
<RadioButton
android:id="#+id/radio0"
android:text="Domandaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minWidth="#dimen/activity_vertical_margin" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radio3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RadioGroup>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup1"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:text="Domanda" />
</RelativeLayout>
This is result:

Related

How do you properly align radio buttons in android studio?

I have three radio groups each with two button inside of them. As you can see from this picture: http://imgur.com/JQJ0a7A [1] ,the buttons are all lined up nicely in android studio. However, when I run the app in the VM I end up with this: http://imgur.com/nKdth41 [2].
Any ideas why this is occurring? Thanks in advance for any help.
xml code:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="onerepmax.reversepyramid.RPworkout">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/workoutButton"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:width="175dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/warmupButton"
android:id="#+id/button3"
android:width="175dp"
android:layout_alignBottom="#+id/button"
android:layout_toRightOf="#+id/button"
android:layout_toEndOf="#+id/button" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/liftText"
android:layout_marginTop="50dp"
android:layout_below="#+id/button"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="xxx lbs"
android:id="#+id/weightText1"
android:layout_marginRight="36dp"
android:layout_marginEnd="36dp"
android:layout_alignTop="#+id/repText1"
android:layout_toLeftOf="#+id/repText1"
android:layout_toStartOf="#+id/repText1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="XX reps"
android:id="#+id/repText1"
android:layout_marginTop="66dp"
android:layout_below="#+id/liftText"
android:layout_alignLeft="#+id/liftText"
android:layout_alignStart="#+id/liftText"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="xxx lbs"
android:id="#+id/weightText2"
android:layout_alignTop="#+id/weightText1"
android:layout_marginTop="70dp"
android:layout_alignLeft="#+id/weightText3"
android:layout_alignStart="#+id/weightText3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="XX reps"
android:id="#+id/repText2"
android:layout_alignTop="#+id/repText1"
android:layout_alignLeft="#+id/repText1"
android:layout_alignStart="#+id/repText1"
android:layout_marginTop="70dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="xxx lbs"
android:id="#+id/weightText3"
android:layout_alignTop="#+id/weightText2"
android:layout_marginTop="70dp"
android:layout_alignLeft="#+id/weightText1"
android:layout_alignStart="#+id/weightText1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="XX reps"
android:id="#+id/repText3"
android:layout_centerVertical="true"
android:layout_alignLeft="#+id/repText1"
android:layout_alignStart="#+id/repText1"
android:layout_alignTop="#+id/repText2"
android:layout_marginTop="70dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/nextButton"
android:id="#+id/nextButton"
android:layout_marginBottom="39dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignRight="#+id/button3"
android:layout_alignEnd="#+id/button3"
android:layout_above="#+id/weightText3"
android:orientation="horizontal"
android:layout_toRightOf="#+id/nextButton"
android:layout_toEndOf="#+id/nextButton"
android:layout_below="#+id/liftText"
android:id="#+id/radioGroup">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton2"
android:checked="false"
android:buttonTint="#2ebb39"
android:layout_marginTop="59dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton"
android:checked="false"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:layout_marginTop="59dp"
android:buttonTint="#d32323"/>
</RadioGroup>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignRight="#+id/radioGroup"
android:layout_alignEnd="#+id/radioGroup"
android:layout_below="#+id/weightText1"
android:layout_alignBottom="#+id/weightText3"
android:orientation="horizontal"
android:layout_toEndOf="#+id/button"
android:layout_toRightOf="#+id/button">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton3"
android:checked="false"
android:buttonTint="#2ebb39"
android:layout_marginTop="45dp"
android:layout_marginLeft="45dp"
android:layout_marginStart="45dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton4"
android:checked="false"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:layout_marginTop="45dp"
android:buttonTint="#d32323"/>
</RadioGroup>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignRight="#+id/radioGroup"
android:layout_alignEnd="#+id/radioGroup"
android:layout_below="#+id/repText2"
android:layout_above="#+id/nextButton">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton5"
android:checked="false"
android:buttonTint="#2ebb39"
android:layout_marginTop="45dp"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton6"
android:checked="false"
android:layout_marginRight="37dp"
android:layout_marginEnd="37dp"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:layout_marginTop="45dp"
android:buttonTint="#d32323"/>
</RadioGroup>
</RelativeLayout>
This should solve your alignment issue, also there is no need to have to label text views, instead do:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="onerepmax.reversepyramid.RPworkout">
<!-- Even spaced buttons above -->
<LinearLayout
android:id="#+id/btn_wrapper"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Workout"
android:id="#+id/button"
android:layout_weight="1"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Warmup"
android:id="#+id/button3"
android:layout_weight="1"/>
</LinearLayout>
<!-- Centered Text -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/liftText"
android:layout_marginTop="50dp"
android:layout_below="#+id/btn_wrapper"
android:layout_centerHorizontal="true" />
<!-- Centered Radio Group with Label 1 -->
<RelativeLayout
android:id="#+id/set_1"
android:layout_below="#+id/liftText"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="?listPreferredItemHeight">
<TextView
android:id="#+id/txt_lbs_1"
android:text="xxx lbs xx reps"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioGroup
android:layout_toRightOf="#+id/txt_lbs_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerVertical="true"
android:id="#+id/radioGroup">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton2"
android:layout_marginLeft="16dp"
android:checked="false"
android:buttonTint="#2ebb39"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton"
android:checked="false"
android:layout_marginLeft="16dp"
android:buttonTint="#d32323"/>
</RadioGroup>
</RelativeLayout>
<!-- Centered Radio Group with Label 2 -->
<RelativeLayout
android:id="#+id/set_2"
android:layout_below="#+id/set_1"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="?listPreferredItemHeight">
<TextView
android:id="#+id/txt_lbs_2"
android:text="xxx lbs xx reps"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioGroup
android:layout_toRightOf="#+id/txt_lbs_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:id="#+id/radioGroup2">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButtonPassTwo"
android:layout_marginLeft="16dp"
android:checked="false"
android:buttonTint="#2ebb39"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButtonFailTwo"
android:checked="false"
android:layout_marginLeft="16dp"
android:buttonTint="#d32323"/>
</RadioGroup>
</RelativeLayout>
<!-- Centered Radio Group with Label 3 -->
<RelativeLayout
android:id="#+id/set_3"
android:layout_below="#+id/set_2"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="?listPreferredItemHeight">
<TextView
android:id="#+id/txt_lbs_3"
android:text="xxx lbs xx reps"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioGroup
android:layout_toRightOf="#+id/txt_lbs_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:id="#+id/radioGroup3">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButtonPassThree"
android:layout_marginLeft="16dp"
android:checked="false"
android:buttonTint="#2ebb39"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButtonFailThree"
android:checked="false"
android:layout_marginLeft="16dp"
android:buttonTint="#d32323"/>
</RadioGroup>
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Workout"
android:id="#+id/nextButton"
android:layout_marginBottom="39dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
And when you want to set something like "200 lbs 10 reps" for the TextView with txt_lbs_1
do:
TextView mTextViewLbs1 = (TextView) findViewById(R.id.txt_lbs_1);
mTextViewLbs1.setText(String.format("%1$d lbs %2$d reps", 200, 3));
This yields:
Good luck and hope this points you in a better direction.
Happy Coding!

how to allow only one radiobtton to be executed in a radiogroup inside a linear layout?

I am trying to place a radio group with 3 radio buttons inside a linear layout. My aim is to choose only one RadioButton inside the RadioGroup but, it is giving me an error that there are multiple root tags. Can someone figure out how to solve this?
file.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ok"
android:id="#+id/textemail"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioButton
android:id="#+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="one" />
<RadioButton
android:id="#+id/two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="two"
/>
<RadioButton
android:id="#+id/three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="three" />
</RadioGroup>
<TextView
android:id="#+id/textView1"
android:layout_below="#+id/textemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To:"
/>
<TextView
android:id="#+id/TextTo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="khushi"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comment:"
/>
<TextView
android:id="#+id/TextS3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="your comment"
/>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="email us "
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="10" />
<Button
android:id="#+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Send"
android:textStyle="italic"/>
</LinearLayout>
You immediately close your radiogroup:
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"/>
This should be:
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"> // Note that there is no forward slash at the end
And you are not closing the RadioGroup:
</RadioButton> <-- This should be </RadioGroup>
Your RadioButton (views) should be children of the RadioGroup(view). By closing your RadioGroup using /> you declare the RadioButton(s) and the RadioGroup as children of the LinearLayout.
The Following should work.
<?xml version="1.0" encoding="utf-8"?>
<Linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"
android:id="#+id/textview"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioButton
android:id="#+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="one" />
<RadioButton
android:id="#+id/two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="two"
/>
<RadioButton
android:id="#+id/three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="three" />
</RadioButton>
</RadioGroup>
<TextView
android:id="#+id/textViewllol"
android:layout_below="#+id/textemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hi:"
/>
<TextView
android:id="#+id/Texme"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="comment:"
/>
<TextView
android:id="#+id/Text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="your comments"
/>
<TextView
android:id="#+id/textView45"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok"
/>
<EditText
android:id="#+id/editTextMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:lines="10" />
<Button
android:id="#+id/button4785"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="send"
/>
</LinearLayout>
Change below -
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"/>
to
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioButton
android:id="#+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="one" />
<RadioButton
android:id="#+id/two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="two"
/>
<RadioButton
android:id="#+id/three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="three" />
</RadioGroup>
One of your Text is not in correct format change it as below -
<TextView
android:id="#+id/textView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok:"
/>
to
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok:"
/>
One more error -
change below -
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent">
to
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
You have one </Radiobutton> tag above </Radiogroup> that shouldn't be here. Just remove it to have :
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioButton
android:id="#+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="one" />
<RadioButton
android:id="#+id/two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="two"
/>
<RadioButton
android:id="#+id/three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="three" />
</RadioGroup>

Adding a horizontalScrollView to bottom navigation bar

I have an activity which contains a table layout and below it I have some buttons, I then implemented a sort of navigation bar using radio group and radio buttons. What I want to do is add a horizontal scroll view to this radio group, however when I try to add it the navigation bar just changes position to the top of the activity to collapse with the table layout and I need this navigation bar to stick to the bottom of the activity. Any help would be much appreciated. Thanks in advance.
Here's my xml code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bckgroundchinese"
android:id="#+id/bottom_layout" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarFadeDuration="0"
android:scrollbarSize="12dip" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#3b3b3b" >
<TableLayout
android:id="#+id/myTableLayout"
android:layout_width="match_parent"
android:layout_height="276dp"
android:background="#drawable/bckgroundchinese" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NO PATIENTS" />
</TableLayout>
</HorizontalScrollView>
</ScrollView>
<Button
android:id="#+id/patient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/radioGroup1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#drawable/buttonchinese"
android:text="Add Patient" />
<Button
android:id="#+id/signtOutDr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/patient"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#drawable/buttonchinese"
android:text="sign out" />
<Button
android:id="#+id/info"
android:layout_width="450dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_above="#+id/alerts"
android:background="#drawable/buttonchinese"
android:text="Edit My Information" />
<Button
android:id="#+id/alerts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/signtOutDr"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#drawable/buttonchinese"
android:text="View Alerts" />
<!--
<HorizontalScrollView
android:id="#+id/scrollView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarFadeDuration="0"
android:scrollbarSize="5dip" >
-->
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="fill_parent"
android:layout_height="71dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#drawable/bckgroundchinese"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/btnAll"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:drawableTop="#drawable/navbar_allselector"
android:gravity="bottom|center_horizontal"
android:text="My Patients" />
<RadioButton
android:id="#+id/btnPicture"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/doctoricon"
android:text="View Assistants" />
<RadioButton
android:id="#+id/btnVideo"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/records"
android:text="Add Assistants" />
<RadioButton
android:id="#+id/btnFile"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/phonebook_"
android:text="Add Patient" />
<RadioButton
android:id="#+id/btnEditInfo"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/phonebook_"
android:text="Edit My Info" />
</RadioGroup>
<!-- </HorizontalScrollView> -->
</RelativeLayout>
Salma i have fixed your problem but removed some background image as it was not existing in my system so take below code and add those background image.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/bottom_layout" >
<HorizontalScrollView
android:id="#+id/mytabview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#3b3b3b" >
<TableLayout
android:id="#+id/myTableLayout"
android:layout_width="match_parent"
android:layout_height="276dp"
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NO PATIENTS" />
</TableLayout>
</HorizontalScrollView>
<!--
<HorizontalScrollView
android:id="#+id/scrollView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarFadeDuration="0"
android:scrollbarSize="5dip" >
-->
<!-- </HorizontalScrollView> -->
<LinearLayout
android:id="#+id/nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/mytabview" >
<Button
android:id="#+id/patient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/buttonchinese"
android:text="Add Patient" />
<Button
android:id="#+id/signtOutDr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/buttonchinese"
android:text="sign out" />
<Button
android:id="#+id/info"
android:layout_width="450dp"
android:layout_height="wrap_content"
android:background="#drawable/buttonchinese"
android:text="Edit My Information" />
<Button
android:id="#+id/alerts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/buttonchinese"
android:text="View Alerts" />
</LinearLayout>
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="fill_parent"
android:layout_height="71dp"
android:layout_alignParentBottom="true"
android:background="#drawable/bckgroundchinese"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/btnAll"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:drawableTop="#drawable/navbar_allselector"
android:gravity="bottom|center_horizontal"
android:text="My Patients" />
<RadioButton
android:id="#+id/btnPicture"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/doctoricon"
android:text="View Assistants" />
<RadioButton
android:id="#+id/btnVideo"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/records"
android:text="Add Assistants" />
<RadioButton
android:id="#+id/btnFile"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/phonebook_"
android:text="Add Patient" />
<RadioButton
android:id="#+id/btnEditInfo"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/phonebook_"
android:text="Edit My Info" />
</RadioGroup>
</RelativeLayout>
you need to move those properties:
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
from the RadioGroup to the HorizontalScrollView, Like this:
<HorizontalScrollView
android:id="#+id/scrollView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:scrollbarFadeDuration="0"
android:scrollbarSize="5dip" >
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="fill_parent"
android:layout_height="71dp"
android:background="#drawable/bckgroundchinese"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/btnAll"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:drawableTop="#drawable/navbar_allselector"
android:gravity="bottom|center_horizontal"
android:text="My Patients" />
<RadioButton
android:id="#+id/btnPicture"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/doctoricon"
android:text="View Assistants" />
<RadioButton
android:id="#+id/btnVideo"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/records"
android:text="Add Assistants" />
<RadioButton
android:id="#+id/btnFile"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/phonebook_"
android:text="Add Patient" />
<RadioButton
android:id="#+id/btnEditInfo"
style="#style/navbar_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:drawableTop="#drawable/phonebook_"
android:text="Edit My Info" />
</RadioGroup>

Android:placing the radio buttons horizontally

Below is my Relative layout..i am trying to place the radio buttons above the edittext
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" >
<ImageView
android:id="#+id/fbreplycancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/fbcancel" />
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="80dp"
android:layout_height="250dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/fbcancel" >
<Spinner
android:id="#+id/replyspinner"
android:layout_width="50dp"
android:layout_height="30dp"
android:layout_alignLeft="#+id/fbshare"
android:layout_alignRight="#+id/fbshare"
android:layout_below="#+id/fbshare"
android:layout_marginTop="16dp"
android:drawSelectorOnTop="true"
android:entries="#array/fbcommentlist"
android:visibility="gone" />
<Button
android:id="#+id/fbshare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/fbbuttons"
android:text="#string/share" />
<ImageView
android:id="#+id/fbpeople"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/fbshare"
android:layout_centerHorizontal="true"
android:layout_marginBottom="19dp"
android:background="#drawable/people2"
android:drawSelectorOnTop="true"
android:paddingTop="20dp" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="RadioButton" />
</RelativeLayout>
<View
android:layout_width="250dp"
android:layout_height="0.7dip"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/imageView1"
android:background="#3b5998" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/fbcancel"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:paddingRight="2dp"
android:src="#drawable/askabud" />
<TextView
android:id="#+id/fbcommentpostedby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/fbedittext"
android:layout_alignRight="#+id/fbcommentdisplay"
android:layout_below="#+id/imageView1"
android:layout_marginTop="15dp"
android:textColor="#000000" />
<TextView
android:id="#+id/fbcommentdisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/fbedittext"
android:layout_below="#+id/fbcommentpostedby"
android:layout_toLeftOf="#+id/relativeLayout1"
android:textColor="#000000" />
<TextView
android:id="#+id/fbtextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_toLeftOf="#+id/fbreplycancel"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/replyrecommend"
android:textSize="18sp"
android:textColor="#000000"/>
<TextView
android:id="#+id/fbplacename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/fbcommentdisplay"
android:layout_alignRight="#+id/fbcommentdisplay"
android:layout_below="#+id/fbcommentdisplay"
android:textColor="#000000" />
<EditText
android:id="#+id/fbedittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/fbplacename"
android:layout_marginLeft="19dp"
android:layout_marginTop="45dp"
android:layout_toLeftOf="#+id/relativeLayout1"
android:background="#drawable/roundcorners"
android:ems="10"
android:hint="#string/fbhint"
android:lines="6"
android:scrollHorizontally="true"
android:textSize="14sp"
android:windowSoftInputMode="stateHidden" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/fbplacename" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="30dp"
android:layout_height="30dp"
android:checked="true"
android:text="1"
/>
</RadioGroup>
<RadioGroup
android:id="#+id/radioGroup2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/radioGroup1"
android:layout_toLeftOf="#+id/relativeLayout1" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="26dp"
android:layout_height="wrap_content"
android:checked="true"
android:text="3" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<RadioButton
android:id="#+id/radio1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignTop="#+id/radioGroup2"
android:layout_toLeftOf="#+id/radioGroup2"
android:text="2" />
</RelativeLayout>
Iam facing a hard time to arrange them horizontally.Any help is appreciated.
To place a radiogroup (or any other view) above other just do:
android:layout_above="#+id/view_below"
To change the orientation just set:
android:orientation="horizontal"
And to give equal width to items make use of layout_weight:
<RadioGroup
android:id="#+id/radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_above="#+id/view_below" >
<RadioButton
android:id="#+id/radio1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:checked="true"
android:text="First" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Second" />
</RadioGroup>
You can use table layout instead of relative layout. Insert row into into table layout and place radio buttons inside table row..
For equal spacing follow following procedure
<TableRow
android:id="#+id/tableRow2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="50dp" >
<RadioButton
android:id="#+id/button2"
android:layout_width="5dp"
android:layout_height="60dp"
android:layout_weight="1"
android:text="#string/btnReject"
android:onClick="onCallRejectButton" />
<RadioButton
android:id="#+id/button1"
android:layout_width="5dp"
android:layout_height="60dp"
android:layout_weight="1
android:onClick="onCallAcceptButton"
android:text="#string/btnAccept" />
</TableRow>
android:orientation="horizontal" just do this. Type the orientation horizontal property to the radiogroup tag
<RadioGroup
android:id="#+id/radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:checked="true" />
<RadioButton
android:id="#+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
You just need to put Radio Group orientation to horizontal.
<RadioGroup
android:id="#+id/radio_group_forgot_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
**android:orientation="horizontal"**
>

ViewFliper in layout

i am doing one application in android but i have one problem in layout file
i am doing by viewFliper
here is code
<?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:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/Quesiontext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="44dp"
android:text="#string/Question"
android:textSize="18sp" />
<RadioGroup
android:id="#+id/radioGroupOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/Quesiontext"
android:layout_marginTop="30dp" >
<RadioButton
android:id="#+id/optionOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/option1" />
<RadioButton
android:id="#+id/optionTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option2" />
<RadioButton
android:id="#+id/optionthree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option3" />
<RadioButton
android:id="#+id/optionFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option4" />
</RadioGroup>
<TextView
android:id="#+id/corrertView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/radioGroupOptions"
android:layout_marginRight="48dp"
android:text="#string/correct" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/corrertView"
android:layout_below="#+id/corrertView"
android:layout_marginTop="42dp"
android:text="#string/Next"
android:textSize="16sp" />
<Button
android:id="#+id/Btnpervious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/btnNext"
android:layout_alignBottom="#+id/btnNext"
android:layout_alignParentLeft="true"
android:text="#string/Pervious"
android:textSize="16sp" />
<RelativeLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewFlipper
android:id="#+id/ViewFlipper01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/Quesiontext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="44dp"
android:text="#string/Question"
android:textSize="18sp" />
<RadioGroup
android:id="#+id/radioGroupOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/Quesiontext"
android:layout_marginTop="30dp" >
<RadioButton
android:id="#+id/optionOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/option1" />
<RadioButton
android:id="#+id/optionTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option2" />
<RadioButton
android:id="#+id/optionthree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option3" />
<RadioButton
android:id="#+id/optionFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option4" />
</RadioGroup>
<TextView
android:id="#+id/corrertView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/radioGroupOptions"
android:layout_marginRight="48dp"
android:text="#string/correct" />
</ViewFlipper>
</RelativeLayout>
</RelativeLayout>
i didnt get it that how i put another button into ViewFliper ..its confusion and generating error...
You haven't closed your ViewFlipper with </ViewFlipper>
Could this be what you are looking for,
android:id="#+id/layout"
You missed a "+" symbol while creating a id.

Categories

Resources