I have the following layout, each time I try to view it in the Graphical Layout it gives the error message below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/my_greeting" />
</LinearLayout>
The error
The following classes could not be found:
- ImageView (Change to android.widget.ImageView, Fix Build Path, Edit XML)
close that file and reopen it. if wont solve the problem just clean and rebuild the project.
It's got to do something with your image source my_greeting. Check if the source name is right and check if you've given a valid extension. Also, try cleaning the project.
Related
I am working on CrimeIntent app in Android Programming:
The Big Nerd Ranch Guide. I got a rendering problem when i put an EditText widget in a LinearLayout file for a fragment (fragment_crime.xml).Here is the code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:id="#+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/crime_title_hint"/>
</LinearLayout>
I do not want to change the theme.
There is no error in your layout xml... possible it is the plugins and library loading issue in android studio... try to restart it or check the missing libraries and targets.. or check the #string/crime_title_hint if it exists in Strings.xml resources.
I am getting this error when I am trying to use an image in Layout file:
Couldn't resolve resource #drawable
Failed to convert #drawable/image into a drawable
Here is my layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/image"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
I tried restart IDE, clean-rebuild but nothing, and I read all threads related to it ( I think ).
And yes my image name contains only [a-z0-9_.].
I had the same problem, I solved it by renaming my image into something like : my_image.
Well, I found a way to avoid this
RightClick on drawable folder then New => File insert its name (myImage)
for example Then Select Image Files.
Then in drawable folder I replaced myImage file with the real image.
Apparently I have duplicate attributes but cannot spot this, I have gone through the XML line by line but cannot see what's wrong. I have tried to clean, build and have also closed eclipse and opened it again. Also this is a new xml file I created in layout as I wanted to change the text displayed within listview instead of using the standard one
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/text1"
android:layout_height="0dp"
android:layout_width ="fill_parent"
android:textSize="20sp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:gravity="center">
</TextView>
Here is a screenshot of where the error is pointing to
SCREENSHOT
ok, it is just an assumption, but the id "text1" is used by android System listview to refer to the internal build textview. Just use another id like
android:id="#+id/my_textview_1"
I guess problem is this line: android:id="#android:id/text1"
change it with this android:id="#+id/text1"
I'm building an Android App using Eclipse. I'm trying to create a simple image display when the application opens.
I've saved my intro_image.png on res\drawable-hdpi in my workspace, I've created another xml for the layout with the following code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/intro_image">
</LinearLayout>
An error message appears when I view the result on the Graphical Layout, saying: "Failed to convert #drawable/into_image into a drawable. Couldn't resolve resource #drawable/intro_image"
How do I solve this?
Thank you.
try to refresh or clean your project. it will work.whenever you paste an image into drawable you have to refresh that folder.
I am trying to add a background to my android project. Heres the code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backround="#drawable/awesome_face">
</RelativeLayout>
I spelled everything out correct but when i go into my graphical layout after saving and nothing shows up. Furthermore after i cleaned the project I now have an error on the
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
saying "no resource identifier found for attribute background in package 'android'" Anyone have ideas?
Just like ChristopheCVB said, your backgroud tag is missing a G.
android:backGround="#drawable/awesome_face">