No resource found that matches the given name keeps showing - android

when am trying to put a background to the layout the app just stops and exit ("unfortunatly, xxxx has stopped working") although the splash and main layouts works fine but as soon as i enter a new layout ex: contact us page ) with no background the app works fine :S :S
here's the code
<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/ibg" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="#drawable/au" />
</LinearLayout>

Try setting another background and check if the problem still exists. I thing there is some problem with your files in drawable folder. Try not setting a .gif image as background and set a jpg or png image.

Related

Splash Screen Background Image color inconsistent

I have a Splash Screen with a background Image on top of it. I have a Video View which plays the video. The background of the video and that of the rest of the screen must match, hence I extracted the background color from the video and added a background image of the same color in the XML file.
The problem is, the color of the image does not match with the video on all versions of Android.
On Sony Xperia SP with v4.3:
On Micromax A1 with v6.0.1:
How do I get consistent result across all (or most) versions of Android?
XML of Splash Screen:
<?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="match_parent"
android:orientation="vertical"
android:background="#drawable/logoback"
>
<VideoView android:id="#+id/myvideo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
Instead of using drawable for setting the background, extract the colour code and set the colour code to background. It might resolve the issue.

How do I get a background image to scale in android studio?

So I am trying to import a custom image as the background of an android app however it does not fill in all of the edges. The option I have seen is to set a second layout to be a frame layout and then place an image view within it with additional coding along the lines of android:scaleType="centerCrop". This will not fill the entire screen up for me however, heres a screenshot of what ends up happening -
Heres the xml code being used:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/backgroundImage"
android:background="#drawable/backgroundImgr"
android:scaleType="centerCrop"
/>
</FrameLayout>
Another issue is that different users use different resolutions so the background image has to be able to accommodate them all without being cut off. I'm not sure how to do this.
Set ScaleType fitXY and add android:adjustViewBounds ="true"
Please use android:src="#drawable/ instead background .I hope it will helps you.

ImageView not showing some images

I'm trying to use the ImageView in Xamarin plug-in for Visual Studio 2012, but when I use png with transparent background like a src I get just black screen.
That's strange but some time ago I could do it, but now I can't. Photo viewer in Visual Studio shows my image just black.
When I run my app on the device I get black screen too.
Here is the XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ImageView
android:src="#drawable/plus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
</LinearLayout>
Previously, I did not have this problem, I think...
If I use the same image in ImageButton and when I use image without transparent background all ok!
Renaming folders Drawable does not help.
How can I resolve this issue?
this is what i think, your image has a transparent background, already, and you also set the widgets background to transparent, now by default your activity or layout theme, by a wild guess has a background of black..so check this out.. Image has a transparent background and the image is a black image, and your widget has a transparent background which tends to show you the theme's background which is black, so your image fades in, to the background image showing the image but since the image itself opage portion is black you get a black Screen this is a wild guess, so do this.. set your linearLayout background to lets say red or white, and everything is gonna be alright
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:background="#fc9" // red or you could do it #fff white
android:minHeight="25px">
<ImageView
android:src="#drawable/plus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
</LinearLayout>
Edit: i misread your question, my error was i tot you also specify transparency for the widget so, i admit my error, but my logic still stays, this time being the fact that, your layout theme is black and every widget follows that because you do not specify it, and your image is black, it still shows black ..
Note this is wild guess..ayt so try it.. and let me know

Why the ImageView class is not found?

i'm having troubles with creating the first android app (Silent Toggle Mode from the pdf "Android.Application.Development.for.For.Dummies" ) with inserting an Imageview in the main.xml file, when I go to the graphical layout, the image isn't showing itself and this error appears:"The following classes could not be found:
- ImageView (Change to android.widget.ImageView, Fix Build Path, Edit XML)"
this is my xml code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="#string/hello_world"
android:orientation="vertical"
tools:context=".MainActivity" >
<EditText android:id="#+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<ImageView
android:id="#+id/phone_icon"
android:contentDescription="#string/description"
android:layout_width="wrap_content"
android:scaleType="fitXY"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/phone_on" />
<Button
android:id="#+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ToggleSilentMode" />
</LinearLayout>
thanks
This is one issue that I have also run across recently. It was sort of a misleading error to me and kept me stumped for around 30 minutes this morning. It isn't that Android cannot find the class. It is that it is having trouble importing the image source file.
Now the reason that it is having trouble finding the image is because I did not copy the source image into the directory correctly. I have chosen to drag the source file from another folder directory into the appropriate locations. In the process, it did not copy the file over properly. Or it copied it over as just a link to the other resource.
As a result Android does not know what to do with the resource and throws that odd error. In order to resolve this problem, you need to delete the old image sources and then replace them with direct full copies of their equivalents. Then you should see this error go away and the application working as expected from the xml layout code.
I faced the same problem once. To get it out, I replaced all the existing images, now it worked.
I had the same issue, when added a new ImageView in my xml with an image src.
I tried to open this image with Photoshop and get an "module format error". So the image was corrupted. The problem was solved creating a new image similar to the first one.
Hope it works :)

Setting background for basic android app

I am currently working on a basic app using eclipse as my IDE. I am currently having trouble setting an image as my background. I was following a tutoral which told me to place my image in the drawable-mdpi folder and name it as icon. I have tried this but it keeps on placing in the andriod icon instead even when i delete the andriod icon image. Is there a better way of doing this?
Thanks
try this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal" android:background="#drawable/background"></LinearLayout>
background is a .png file. with borders draw around it with Nine9Patch.
Hope this helps

Categories

Resources