In the android preview screen in eclipse, I see the following: https://dl.dropboxusercontent.com/u/63060352/379d2a92a0b1f8300d25ff15bf5bcbae.png
But when I run the app on my phone, the "Feedback" and "Suggestions or feedback? Let us know." textViews are not there, but the others are. I am confused why these aren't showing when I run the app on my phone and on the emulator.
Here's my XML:
<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/info_screen_high"
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=".InfomenuActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="154dp"
android:layout_toRightOf="#+id/textView1"
android:src="#drawable/star_rating_medium" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="149dp"
android:text="Rate It"
android:textColor="#FFFFFF"
android:textSize="32sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/imageView1"
android:layout_marginTop="14dp"
android:text="Rate this app in the market!"
android:textSize="17dp"
android:textColor="#B6B6B4" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_marginTop="20dp"
android:text="Tell a friend"
android:textColor="#FFFFFF"
android:textSize="29dp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_centerVertical="true"
android:text="Spread the word about the app!"
android:textColor="#B6B6B4"
android:textSize="17dp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_below="#+id/textView4"
android:layout_marginTop="285dp"
android:text="Feedback"
android:textColor="#FFFFFF"
android:textSize="29dp" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView5"
android:layout_below="#+id/textView5"
android:text="Suggestions or feedback? Let us know."
android:textColor="#B6B6B4"
android:textSize="18dp" />
</RelativeLayout>
If anyone could help me out, that would be much appreciated!
You have android:layout_marginTop="285dp" in the textView5, is too much! You can put something like 30dp and it is going to work
have you tried to remove these paddings, might be this problem.
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
can u show us a snapshot of this screen appearing in device.
Related
Newbie to android, Stuck with aligning the button to center of the screen.
here the 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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.kissmat.gbrf_ebook.SingupIntro"
android:background="#drawable/lib_gradient">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Author"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:layout_marginLeft="70dp"
android:layout_marginStart="70dp"
android:layout_marginTop="82dp"
android:id="#+id/authorBtn"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:elegantTextHeight="true"
android:drawableTop="#drawable/author" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:drawableTop="#drawable/publisher"
android:text="PUBLISHER"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:id="#+id/pubBtn"
android:layout_alignTop="#+id/authorBtn"
android:layout_toRightOf="#+id/authorBtn"
android:layout_toEndOf="#+id/authorBtn"
android:layout_marginLeft="48dp"
android:layout_marginStart="58dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:drawableTop="#drawable/student"
android:text="STUDENT"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:layout_marginTop="57dp"
android:id="#+id/stbBtn"
android:layout_below="#+id/authorBtn"
android:layout_alignLeft="#+id/authorBtn"
android:layout_alignStart="#+id/authorBtn" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:drawableTop="#drawable/user"
android:text="READER"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:id="#+id/readerBtn"
android:layout_alignTop="#+id/stbBtn"
android:layout_alignLeft="#+id/pubBtn"
android:layout_alignStart="#+id/pubBtn" />
</RelativeLayout>
How it looks when i run on the device.
I just removed the margins (Left, Start and Top) from your first button and added the property android:gravity="center" to your layout. The last one positions the contents in the center. There's no need to do that with fixed margin values. This is very helpful as your layout will be centered in all the different screen sizes and pixel densities.
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.kissmat.gbrf_ebook.SingupIntro"
android:background="#drawable/lib_gradient"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Author"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:id="#+id/authorBtn"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:elegantTextHeight="true"
android:drawableTop="#drawable/author" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:drawableTop="#drawable/publisher"
android:text="PUBLISHER"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:id="#+id/pubBtn"
android:layout_alignTop="#+id/authorBtn"
android:layout_toRightOf="#+id/authorBtn"
android:layout_toEndOf="#+id/authorBtn"
android:layout_marginLeft="48dp"
android:layout_marginStart="58dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:drawableTop="#drawable/student"
android:text="STUDENT"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:layout_marginTop="57dp"
android:id="#+id/stbBtn"
android:layout_below="#+id/authorBtn"
android:layout_alignLeft="#+id/authorBtn"
android:layout_alignStart="#+id/authorBtn" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:drawableTop="#drawable/user"
android:text="READER"
android:textColor="#ffffffff"
android:background="#00ffffff"
android:id="#+id/readerBtn"
android:layout_alignTop="#+id/stbBtn"
android:layout_alignLeft="#+id/pubBtn"
android:layout_alignStart="#+id/pubBtn" />
</RelativeLayout>
This happened yesterday when i was replacing a few elements in my XML. When I went to my main class, I saw that all references to R had been marked red, and I was told that R could not be resolved to a variable. At first, I tried to rebuild and clean up my project, but that didn't work, so I am assuming that the issue lies in the XML file I recently edited, however I do now know where the issue would lie. And yes, I did make sure android.R was not being imported.
A few additional details:
I am using Android 5.0 (API 21)
The R issues do not appear in my other class files, which reference R.
Here is the XML file in question:
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_marginTop="20dp"
android:text="#string/rye"
android:textColor="#888888"
android:textAppearance="?android:textAppearanceLarge" />
<RatingBar
android:id="#+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:isIndicator="false"
android:numStars="5"
android:stepSize="1" />
<Button
android:id="#+id/dropDownButton"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_alignBottom="#+id/ratingBar1"
android:layout_toRightOf="#+id/ratingBar1"
android:onClick="dropDown"
android:text=">"/>
<RelativeLayout
android:id="#+id/dropDownLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/textView2"
android:visibility="gone" >
<TextView
android:id="#+id/testTV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Testing dropdown" />
</RelativeLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tipTitle"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888"
android:layout_below="#+id/quizFragment"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<FrameLayout
android:id="#+id/quizFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/dropDownButton" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/people_dining_title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888"
android:layout_below="#+id/seekBar3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/subtotalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/subtotal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888"
android:layout_below="#+id/seekBar2"
android:layout_alignLeft="#+id/seekBar2"
android:layout_alignStart="#+id/seekBar2" />
<TextView
android:id="#+id/totalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/subtotalText"
android:layout_below="#+id/subtotalText"
android:layout_marginTop="10dp"
android:text="#string/total"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888" />
<TextView
android:id="#+id/totalText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/subtotalText"
android:layout_alignRight="#+id/subtotalText"
android:layout_below="#+id/totalTitle"
android:focusable="false"
android:padding="2dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffff000c" />
<EditText
android:id="#+id/subtotalText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/subtotalTitle"
android:ems="10"
android:hint="SUBTOTAL"
android:inputType="numberDecimal"
android:padding="2dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ff0000"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/seekBar2"
android:layout_alignEnd="#+id/seekBar2">
</EditText>
<TextView
android:id="#+id/eppTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/totalText"
android:layout_below="#+id/totalText"
android:layout_marginTop="10dp"
android:text="#string/epp"
android:textColor="#888888"
android:textAppearance="?android:textAppearanceMedium" />
<TextView
android:id="#+id/eppText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/eppTitle"
android:layout_alignRight="#+id/totalText"
android:layout_below="#+id/eppTitle"
android:focusable="false"
android:padding="2dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/buttonDone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/eppText"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:onClick="done"
android:text="#string/done"
android:textStyle="bold" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar2"
android:layout_below="#+id/TextView02"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar3"
android:layout_below="#+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>
I am not able to see any issues in this xml file . Can you also post the code for the class file where you are using it and check if you're not using android.r and using com.yourapp.r . This might be the case. Could you post the class also
I made an application for android, and it was loading fine in the emulator and phone, and then I made some minor changes like shifting the position of text View elements in the layout with help of "Graphical Layout" editing option in Eclipse. and after that the application no longer starts, it just loads with a blank activity and in 2-3 seconds crashes.
The layout that I am using looks like this currently (and this is the crashing state of layout):
<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=".BMI" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText1"
android:layout_alignLeft="#+id/textView2"
android:text="#string/weight"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginLeft="15dp"
android:layout_marginTop="30dp"
android:text="#string/button1_text" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_toRightOf="#+id/textView3"
android:ems="4"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText2"
android:layout_below="#+id/editText2"
android:ems="4"
android:inputType="numberDecimal" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_alignParentTop="true"
android:text="#string/bmi"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText2"
android:layout_alignParentTop="true"
android:text="#string/default_text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView4"
android:layout_marginLeft="17dp"
android:text="#string/height"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button1"
android:layout_alignBottom="#+id/button1"
android:layout_toRightOf="#+id/editText1"
android:text="#string/button2_text" />
</RelativeLayout>
Try cleaning and rebuilding the project by going to "Project --> Clean..." then run the app again. After making changes in Eclipse to the layout, sometimes Eclipse doesn't "get" the changes right away so you end up with a goofy ClassCastException. A cleaning usually fixes this.
If this doesn't solve your problem then please post the logcat from the crash but this should do the trick.
I had several problems with Android build tool on both Eclipse and IntelliJ. Usually result in xml file doesn't get updated or shift up or down by a line or two. Usually, by rebuilding the project or restarting your IDE would fix this problem.
// try this
<?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=".BMI" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText1"
android:layout_alignLeft="#+id/textView2"
android:text="#string/weight"
android:textAppearance="#android:style/TextAppearance.Medium" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginLeft="15dp"
android:layout_marginTop="30dp"
android:text="#string/button1_text" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_toRightOf="#+id/textView3"
android:ems="4"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText2"
android:layout_below="#+id/editText2"
android:ems="4"
android:inputType="numberDecimal" >
</EditText>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_alignParentTop="true"
android:text="#string/bmi"
android:textAppearance="#android:style/TextAppearance.Medium" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText2"
android:layout_alignParentTop="true"
android:text="#string/default_text"
android:textAppearance="#android:style/TextAppearance.Medium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView4"
android:layout_marginLeft="17dp"
android:text="height"
android:textAppearance="#android:style/TextAppearance.Medium"/>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button1"
android:layout_alignBottom="#+id/button1"
android:layout_toRightOf="#+id/editText1"
android:text="#string/button2_text" />
</RelativeLayout>
When I am trying to look at my graphical layout this message appears in the error log:
activity_main.xml: Circular dependencies cannot exist in RelativeLayout.
How would I go about correcting this so my code will work correctly?
I have changed around the alignParentLeft and set them to true. I have also messed around with the align_above and align_below which hasn't helped. I'm not sure what my problem is.
Here is my 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: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=".MainActivity" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="57dp"
android:text="Number of cups" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView1"
android:layout_marginRight="23dp"
android:layout_toRightOf="#+id/textView1"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<CheckBox
android:id="#+id/go"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/cream"
android:layout_alignParentLeft="true"
android:layout_marginBottom="20dp"
android:text="To Go" />
<CheckBox
android:id="#+id/cream"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/sugar"
android:layout_alignParentLeft="true"
android:layout_marginBottom="15dp"
android:text="Leave room for cream" />
<CheckBox
android:id="#+id/sugar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/drinks"
android:layout_alignParentLeft="true"
android:layout_marginBottom="22dp"
android:text="Leave room for sugar" />
<RadioGroup
android:id="#+id/drinks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/sugar"
android:layout_above="#+id/flavoring"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true" >
<RadioButton
android:id="#+id/coffee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Coffee($2.50)" />
<RadioButton
android:id="#+id/cappuccino"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Cappucino($4.50)" />
<RadioButton
android:id="#+id/espresso"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Espresso($4.50)" />
<RadioButton
android:id="#+id/latte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Latte($4.50)" />
<RadioButton
android:id="#+id/iced_latte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Iced Latte($5.00)" />
</RadioGroup>
<TextView
android:id="#+id/flavoring"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/chocolate"
android:layout_alignParentLeft="true"
android:layout_marginTop="57dp"
android:text="Flavoring" />
<CheckBox
android:id="#+id/chocolate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/cherry"
android:layout_alignParentLeft="true"
android:layout_marginBottom="22dp"
android:text="Chocolate" />
<CheckBox
android:id="#+id/cherry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/vanilla"
android:layout_alignParentLeft="true"
android:layout_marginBottom="22dp"
android:text="Cherry" />
<CheckBox
android:id="#+id/vanilla"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/cherry"
android:layout_alignParentLeft="true"
android:layout_marginBottom="22dp"
android:text="Vanilla" />
<ScrollView
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignLeft="#+id/editText1"
android:layout_alignParentBottom="true" >
</ScrollView>
</RelativeLayout>
These are your problems
<CheckBox
android:id="#+id/sugar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/drinks"
android:layout_alignParentLeft="true"
android:layout_marginBottom="22dp"
android:text="Leave room for sugar" />
<RadioGroup
android:id="#+id/drinks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/sugar"
android:layout_above="#+id/flavoring"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true" >
You are telling sugar to be above drinks and for drinks to be below sugar. You can only do one of these or they get into an infinite circle. So remove android:layout_below="#+id/sugar" from drinks RadioGroup.
I don't see yet if you have this anywhere else but if you do then you will need to fix those, also. You can't tell a View to be above another and tell that View to be below the same View...same with left and right.
Edit found another
<CheckBox
android:id="#+id/cherry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/vanilla"
android:layout_alignParentLeft="true"
android:layout_marginBottom="22dp"
android:text="Cherry" />
<CheckBox
android:id="#+id/vanilla"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/cherry"
android:layout_alignParentLeft="true"
android:layout_marginBottom="22dp"
android:text="Vanilla" />
You have the same thing going on here. You will need to remove the above or the below from one of these.
I am new to android.Wen I run this apk file in my phone,it runs and wen I rotate for a horizontal view,it shows only half a page and if I try to scroll,it doesnt scroll.I tried a lot using ScrollView.It is not getting Implemented.the error wch occurs is :"activity_main.xml: ScrollView can host only one direct child".Can someone suggest me how to solve it??
<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=".MainActivity" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_centerHorizontal="true"
android:text="LOGIN"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imageView1"
android:layout_marginTop="49dp"
android:text="Username"
android:textSize="20sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/editText3"
android:layout_marginTop="17dp"
android:text="Password"
android:textSize="20sp" />
<TextView
android:id="#+id/link_to_register"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/button1"
android:layout_below="#+id/button1"
android:layout_marginTop="14dp"
android:gravity="center"
android:text="Forgot Password"
android:textColor="#0b84aa"
android:textSize="20dip" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_marginTop="26dp"
android:layout_toLeftOf="#+id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView1"
android:layout_alignLeft="#+id/editText4"
android:ems="10"
android:inputType="textEmailAddress" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_marginTop="42dp"
android:layout_toLeftOf="#+id/textView1"
android:ems="10" />
<EditText
android:id="#+id/editText4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentRight="true"
android:layout_marginLeft="100dp"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText3"
android:layout_below="#+id/editText4"
android:layout_marginTop="23dp"
android:background="#9ACD32"
android:text="Log In" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView1"
android:layout_below="#+id/imageView2"
android:scaleX="1.5"
android:scaleY="1.5"
android:src="#drawable/igs_login" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="21dp"
android:layout_toRightOf="#+id/button1"
android:src="#drawable/igs" />
The error says it very clearly ScrollView can host only one direct child. That means when you are using ScrollView you should consider creating a layout which holds all views in it and add your ScrollView as it's parent. For example :
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
//ADD YOUR VIEWS ONLY HERE
</RelativeLayout>
</ScrollView>
You layout should look like this! Instead of RelativeLayout, you can use whenever layout you want, but just remember: All views should be added in one layout!
ScrollView can host only one child, such as RelativeLayout or LinearLayout (or any other View extending VIewGroup, so your implementation should be something like this:
<ScrollView>
<LinearLayout>
here you can put how many Views you need
</LinearLayout>
</ScrollView>