i got error : Exception raised during rendering this$0
this is my xml :
<?xml version="1.0" encoding="utf-8"?>
ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:padding="#dimen/activity_horizontal_margin"
android:id="#+id/fairy_animation"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
style="#android:style/TextAppearance.Medium"
android:id="#+id/textview_language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/layout_container"
android:layout_alignBaseline="#+id/button_language"
android:gravity="center_horizontal"
android:text="#string/text_is_in"/>
<Spinner
tools:listitem="#android:layout/simple_spinner_item"
android:id="#+id/button_language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/layout_container"
android:drawSelectorOnTop="true"
android:layout_toRightOf="#+id/textview_language"
android:layout_toEndOf="#+id/textview_language"/>
</RelativeLayout>
i don't understand how to fix it. please help. i'm new at this. i'm using android studio 2.0
This issue comes from this line:
tools:listitem="#android:layout/simple_spinner_item"
You can avoid it by removing it or use a different layout. (e.g. simple_list_item_1)
Looks like the same basic issue: https://code.google.com/p/android/issues/detail?id=209139
You have to
change ScrollView.....> to <ScrollView.....>
Add </SCrollView> after </RelativeLayout>
Refer xml rules to gain more knowledge.
Related
when first defining id ( #+id ) in constraint part ( such as app:layout_constraintBottom_toTopOf ) i get the error "cannot resolve symbol"
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/tv2" />
<TextView
android:id="#id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>
see the screen shot:
In gradle I have constraint layout 1.1.3 and Android studio version is 3.2.1 I recently updated it from older version:
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
app runs correctly without any error but the error is shown in android studio layout window.
Invalidating caches, rebuilding, and changing constraint layout version NONE of them helps!
In Java class R.id.tv2 works correctly and when i control+click it I can see its field in R class. editor is using another class for ids that is not same as the R class in java code?
This question was about a bug in old Android Studio and ConstraintLayout versions in current versions of Android Studio using androidx library this bug is not presented.
The plus sign + is added when defining the id (#+id/tv2) but when referencing you don't need to add the plus sign like this #id/tv2.
Instead of this
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/tv2" />
<TextView
android:id="#id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>
use this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#id/tv2" />
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>
To get it right I suggest you convert your code to Androidx.
The below code is written in Androidx
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#id/tv2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Screenshot
As already mentioned in the other answers, use #+id/<your_name> to declare new resources.
In my case, Android Studio complained when using the - character in names (even though the app compiled and worked either way).
This question was about a bug in old Android Studio and ConstraintLayout versions in current versions of Android Studio using androidx library this bug is not presented.
1) I'm seeing "unknown drawble resource" error when I use:"android:src="#drawble/party""
The complete code is shown below. What's the issue as my "party.jpg" file is under res/drawble folder?
2) I also see an error with "android:layout_alignRight="8dp"" What's the issue here?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="park.hannah.myapplication.MainActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawble/party" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From. Hyunji"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Happy Tuesday!!"
android:layout_alignRight="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
YOU HAVE SYNTAX ERROR
#drawable/party instead of #drawble/party
use this
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/party" />
I also see an error with "android:layout_alignRight="8dp"" What's the
issue here?
you must align a view depend on another view by ID
suggestions
you can also use gravity right instead of android:layout_alignRight for not complex view layouts
try to use LinearLayout easy and comfort for not complex view layouts
rename your drawable from *.jpg to *.png
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.
I am new in Android and I tried to create a tab using FragmentActivity from codes that I found online.
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
This is my FragmentActivity http://pastie.org/pastes/5170802/text?key=jhowuevxe2fshlwu5tisg
I would like to use a custom layout that uses an image and text.
//tab_indicator.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dip"
android:layout_height="55dip"
android:layout_weight="1"
android:orientation="vertical"
android:background="#drawable/tab_indicator"
android:padding="5dp">
<ImageView android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/icon"/>
<TextView android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
style="?android:attr/tabWidgetStyle"/>
</RelativeLayout>
I found a similar question here : create custom tab in FragmentActivity but I couldn't figure it out how to apply the solution in my codes. Can someone teach me how? Thank you.
Update:
I managed to inflate the custom layout in my codes. But I faced another error. This is my latest codes http://pastie.org/pastes/5187362/text?key=74r87diquysvruwsam1tq tweaked to FragmentActivity, from AdilSoomro http://adilsoomro.blogspot.com/2011/06/iphone-like-tabs-in-android.html codes (which uses TabActivity) with some references from
http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
My latest codes successfully inflate the layout like this, with the setting http://pastie.org/pastes/5187408/text?key=qxxa5xxrhsburebllyhmw for its layout (tab_indicator.xml)
but I need to align my tab to the bottom. When I align it to the bottom, the code layout_gravity="bottom" worked on Graphical Layout but when I run it, my relative layout's background fill the whole screen, like this with the code http://pastie.org/pastes/5187445/text?key=6dz2tsiggey9se51d2thtq
can someone tell me what I did wrong?
Solved it! Finally! After testing other resources that I referred to, I realized that layout_alignParentBottom in RelativeLayout does not give any outcome. Hence I tried aligning the TabWidget to the bottom instead, and it worked!
This is my main.xml that contain TabHost and TabWidget.
http://pastie.org/pastes/5188297/text?key=lqfp3jnofs5kgsvslm3yg
Keep the tab_indicator.xml / the settings for the text and image like this : http://pastie.org/pastes/5187408/text?key=qxxa5xxrhsburebllyhmw
And here is the a custom iPhone tab that uses FragmentActivity :
P/S : Sorry if my Java file is confusing, I'm new and if there is anything I did wrong, do tell me.
try this Honey >
<?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="55dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="bottom"
android:background="#android:drawable/title_bar"
android:padding="5dp">
<TextView android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
style="?android:attr/tabWidgetStyle"/>
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_action_search" />
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="49dp"
android:src="#drawable/ic_action_search" />
</RelativeLayout>
I was trying to do an adapter on a ListView as an exercise but I get a strange error on the row layout:
error: Error parsing XML: unbound prefix
What is wrong with this very simple Layout??!?
<?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">
<TextView
android:id="#+id/station"
android:text="Stazione DI"
android:layout_alignParentTop="true"
android:padding="3dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
androdi:id="#+id/time"
android:text="Time:"
android:layout_alignParentLeft="true"
android:below="#id/station"/>
<TextView
androdi:id="+id/late"
android:text="Time:"
android:layout_toRightOf="#id/time"
android:below="#id/station"/>
<TextView
androdi:id="+id/rail"
android:text="Rail:"
android:below="#id/station"
android:layout_toRightOf="#id/late"/>
</RelativeLayout>
Prefixes are those strings you type before the :, like android:.... And you typed it wrong once (androdi:...)
(edit: actually 3 times)
Prefixes in Last TextView spell not correct, check that
In xml file last Textview is worong
<TextView
androdi:id="+id/rail"
android:text="Rail:"
android:below="#id/station"
android:layout_toRightOf="#id/late"/>
It will be
<TextView
android:id="+id/rail"
android:text="Rail:"
android:below="#id/station"
android:layout_toRightOf="#id/late"/>
you have written android spelling wrong in following cases !
androdi:id="#+id/time"
androdi:id="+id/late"
androdi:id="+id/rail"