After recently updating eclipse i keep getting an error saying "Attribute name "android:tools" associated with an element type "RelativeLayout" must be followed by the ' = ' character.
It says it on line 9 but there isn't any android:tool there. I've tried cleaning and restarting eclipse and still no solution. I never changed any part of the file, and the funny thing is all my other activities are the same and don't have any errors. Any help would be appreciated thanks.
Edit... I fixed the problem by deleting the file and creating a new one. File must have been corrupt or something. Thanks for the input everyone, sorry for the run confusion.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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="wrap_content"
android:background="#color/backtext"
tools:context=".Brakes"
android:screenOrientation="portrait" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="#string/brakes1"
android:textColor="#color/textviews"
android:textSize="15sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView2"
android:text="#string/brakes2"
android:textColor="#color/textviews"
android:textSize="15sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView3"
android:text="#string/brakes3"
android:textColor="#color/textviews"
android:textSize="15sp"/>
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView4"
android:text="#string/brakes4"
android:textColor="#color/textviews"
android:textSize="15sp"/>
</RelativeLayout>
</ScrollView>
Try moving this line:
xmlns:tools="http://schemas.android.com/tools"
to your ScrollView instead of the RelativeLayout where it is now.
it looks like your RelativeLayout used to be your root view, and you added the ScrollView at some point later.
you are missing xmlns:tools="http://schemas.android.com/tools" in your root parent,please include it.
Remove xmlns:android="http://schemas.android.com/apk/res/android" from your RelativeLayout. There should be only one of those at the layout root element.
Related
enter image description here
please see the pic. How can I fix this error? I tried installing a couple other devices, checked some function for hardware vs software graphics. TIA
<android.support.constraint.ConstraintLayout 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="match_parent"
tools:context="haroonahmad.berkeleysucksapp.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Berkeley Admisions"
android:textSize="24sp"
tools:layout_editor_absoluteY="88dp"
tools:layout_editor_absoluteX="88dp" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="335dp" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
tools:layout_editor_absoluteX="268dp"
tools:layout_editor_absoluteY="335dp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Points: 0"
tools:layout_editor_absoluteX="163dp"
tools:layout_editor_absoluteY="415dp" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="495dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp">
</RelativeLayout>
edit: sorry i'm a completely new to adding code, didn't realize I could only add to the first post.
I tried changing the ConstraintLayout in both places to RelativeLayout, didn't work. then tried right clicking on the resource file and changed the layout and layoutvertical to RelativeLayout, and still didn't work. thanks for any further suggestions
You're probably using a root layout that does not match the alignments you're setting in other views. Try using RelativeLayout as root layout.
Maybe if you post your XML layout, it is easier for us to identify the problem.
OK I fixed it by changing the whole text before xmlns to RelativeLayout. thanks for the tip!
I just created a new projet, building some layouts, writing some code. Everything was fine except I got this error as shown in the picture below.
I tried to remove and type it again and when typing 'R.id.', there was no 'container' showing up in the list. So that means theres no problem with my R file, just that the 'container' word lost somewhere.
Those code above are actually default code in onCreate() method in your main activity everytime you create a new project in Android Studio. (I actually tried to create a new project to compare and yes it's the same, and without error as it's brand new.).
All I did was comment out the if statement block so the error goes away, and the application has run just fine on the emulator. I just don't know why I got that problem and how I can handle it as I may need to do that in the future. Thank you!
Edit after #Raghunandan has mentioned: Below is my xml.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/provide_information"
android:id="#+id/provideInfoButton"
android:layout_alignParentTop="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/take_picture"
android:id="#+id/takePictureButton"
android:layout_below="#+id/provideInfoButton"
android:layout_alignParentLeft="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_below="#+id/takePictureButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/classNameTextView"
android:layout_above="#+id/personNametextView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="44dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginBottom="38dp"
android:layout_above="#+id/emailTextView"
android:layout_alignLeft="#+id/emailTextView"
android:id="#+id/personNameTextView" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/emailTextView"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#+id/classNameTextView"
android:layout_marginBottom="82dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/send_button"
android:id="#+id/sendButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
The reason is that I changed the root layout to RelativeLayout (the default of Android Studio was FrameLayout which has an id of "container"). My bad :). Thanks for mentioning about posting the xml file. I have not noticed that as I'm not as familiar with Android Studio as with Eclipse yet.
I have a rather simple ListView row:
<?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="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tournament_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="25dp" />
<TextView
android:id="#+id/tournament_winner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="25dp" />
</RelativeLayout>
When the text of "#+id/tournament_name"is long - it overlaps with the one from "#+id/tournament_winner" and I don't understand why.
I tried using android:singleLine="false"to no avail. I also tried using android:inputType="textMultiLine"as the docu says android:singleLine="false" is deprecated but then I get the warning: Attribute android:inputType should not be used with <TextView>: Change element type to
<EditText> ? so no good here as well.
I also tried using android:ellipsize="end" but this doesn't work. I assume it is because the text in the left TextView ("#+id/tournament_name") is NOT long enough to fill up the full width of the ListView (which code is not sowing here).
I was sure that if I use android:layout_width="wrap_content"the two TextView fields shouldn't overlap.
Here is an example (see the second line):
Any further ideas how this could be fixed?
android:layout_toLeftOf="#id/tournament_winner" in First TextView.
Also set android:maxLines="1" and Fix width for tournament winner because when it gets long tournament name cant see...
row.xml
<?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="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tournament_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/tournament_winner"
android:maxLines="1"
android:text="NAMEEEEEEEEEEEEEEEEEEEEEEEEEEE"
android:textSize="25dp" />
<TextView
android:id="#+id/tournament_winner"
android:layout_width="wrap_content" android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="WINER"
android:textSize="25dp" />
</RelativeLayout>
Thank you very much for your answer - sorry it took me some time to respond. I ended up using your android:layout_toLeftOf="#+id/tournament_winner" but left the single line and the margin to the left unused, as the result seemed perfect to me (hope this is also the case for other devices).
One thing though - in the first text view (tournament_name) I had to use android:layout_toLeftOf="#+id/tournament_winner"and not android:layout_toLeftOf="#id/tournament_winner" - pay attention to the added +. For some reason I get an error using android:layout_toLeftOf="#id/tournament_winner": Error: No resource found that matches the given name... so it seems that it is possible and NEEDED to define the resource in the time of calling it because the system doesn't know it before it was defined.
<?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="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tournament_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/tournament_winner"
android:layout_alignParentLeft="true"
android:textSize="25dp" />
<TextView
android:id="#+id/tournament_winner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="25dp" />
</RelativeLayout>
You can use single text view in place of two and simply display both strings in one text view !!
I am trying to view my android xml file layout design-view but it is not displaying,I did some designing in XML with eclipse and ADT,
When I click on Graphical Layout it does not display anything and says 'Missing Theme',I also tried : Right click XML file>openwith>android layout editor but to no avail.
My development environment is:
Eclipse Helios Service Release 2,
Android Development Toolkit Version: 12.0.0.v201106281929-138431,
Dalvik Debug Monitor Service Version: 12.0.0.v201106281929-138431,
Traceview Version:12.0.0.v201106281929-138431.
What can be the problem` ?
My xml file as below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/RelativeLayout01"android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:id="#+id/ScrollView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout1">
<RelativeLayout android:id="#+id/RelativeLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<RelativeLayout android:id="#+id/RelativeLayout05"
android:layout_below="#id/RelativeLayout04" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#color/brightblue">
<TextView android:id="#+id/TextView06"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="#string/SaveMyBackupTo" android:textColor="#color/black"
android:textStyle="bold" android:layout_marginLeft="5dip"
android:lines="2" android:layout_alignParentLeft="true"
android:singleLine="false" android:layout_toLeftOf="#+id/Button09"
android:layout_marginTop="5dip"></TextView>
<CheckBox android:id="#+id/CheckBox01" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:text="#string/EnableAutoSave"
android:textColor="#color/black" android:layout_below="#+id/Button09"></CheckBox>
<Button android:id="#+id/Button09" android:layout_alignParentRight="true" android:textSize="12dip"
android:layout_width="wrap_content" android:layout_height="30dip"
android:text="Memory Card" android:layout_marginTop="5dip"></Button>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I uploaded a screenshot here.
one thing i noted that my title-bar selection option menu is not change-able.
Try changing the SDK level/version from the drop-down. it solved this issue for me everytime.
I had the same issue. solution posted here.
In main activity of my application I need a control which should look like ListPreference in PreferencesActivity. I mean, 2 lines: title and current value and down arrow icon on the right.
I've tried to use TwoLineListItem for this:
<TwoLineListItem android:id="#+id/twoLineListItem1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:onClick="onButtonClick" android:focusable="true"
android:background="#android:drawable/list_selector_background">
<TextView android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content" android:id="#android:id/text1"
android:text="Upload into:" />
<TextView android:layout_below="#android:id/text1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignLeft="#android:id/text1" android:layout_height="wrap_content"
android:id="#android:id/text2" android:text="<not set>"
android:layout_width="wrap_content" />
<!-- <ImageView android:layout_width="wrap_content" android:layout_alignParentRight="true"
android:id="#android:id/selectedIcon"
android:src="???"> </ImageView> -->
</TwoLineListItem>
It all works except of arrow icon: I can't find proper resource which system uses for it.
How this could be solved?
Or maybe I should use another control instead of TwoLineListItem?
Or maybe even try to implement my activity as PreferencesActivity (thought I need some EditText controls in my activity)?
For the reference, what I need is on the left picture:
http://androinica-serve.s3.amazonaws.com/wp-content/uploads/2010/11/evernote_comp2.png
wow, this question is so old and i can't believe no one answered it correctly lol. the layout you were looking for is in the sdk tree under:
[android-sdk-root]/platforms/[your-platform]/data/res/layout/preference.xml
you'll find this and any other sdk defined layouts in this folder. fish around in the res folder and see what's available. sorry it's a year late, but there ya go.
Use this layout and modify according to your need...
<?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"
android:background="#FFFFFF">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentLeft="true">
<TextView android:layout_width="fill_parent"
android:text="ggggggggg"
android:layout_height="wrap_content" android:id="#android:id/text1"
/>
<TextView android:layout_below="#android:id/text1"
android:text="ssssssssssss"
android:layout_height="wrap_content"
android:id="#android:id/text2"
android:layout_width="wrap_content" />
</LinearLayout>
<ImageView android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:id="#android:id/selectedIcon"
android:layout_height="wrap_content"
android:src="#drawable/icon"
/>
</RelativeLayout>
You might try using #android:drawable/btn_dropdown to get the system resource and setting that as the background.