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">
Related
When the application is launched, my layout is displayed for a very short second and then disappears. As a beginner in Kotlin, I don't understand why it produces this result.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="univ.master.kotlin.weather.city.CityFragment">
<fragment
android:id="#+id/city_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="univ.master.kotlin.weather.city.CityFragment"/>
</LinearLayout>
It's just a message from the preview window telling you that it can't show a preview for the fragment tag due to not knowing what kind of fragment you'll insert. When you run your actual app, the fragment will render fine.
try to add :
tools:layout="#android:layout/YOUR_LAYOT"
<fragment
android:id="#+id/city_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#android:layout/YOUR_LAYOT"
android:name="univ.master.kotlin.weather.city.CityFragment"/>
Thank you for sharing your xml and java code. If you tried everything and still layout is not appring it is just because of android studio is not able to catch you .xml code not to worry.
You can Select all xml code ctrl+A>ctrl+X>ctrl+V Don't ask me how.
I don't even know how but it works for me. You can also try this because this is the android studio universal rule
Rebuild project or Clear catch and restart
Hope it helps
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 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.
After doing a lot of research, and not finding anything... quick question, does anybody has an idea why Android Studio is not taking the Map tag? The code below is a fragment of the maps sample in the SDK. Already added google play services lib and support, but nothing.
It's showing the error
Unexpected namespace prefix "map" found for tag fragment.
Thanks a lot in advance!
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraZoom="10" />
I had the same problem once I've been moving the map fragment into FrameLayout (so I could add a button on top of the map).
I don't know what I've really done as I'm a noob in Android apps and XML, but it looks that I found the solution :-)
I tried to make the trick including the fragment from a separate file (using 'include' directive) and once I put the bare map fragment without any namespace definitions it proposed me 2 options:
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:map="http://schemas.android.com/tools"
I realized that maybe the 2nd one will work in the original file (although in original file Android Studio is not proposing it, but only the 1st one instead).
Conclusion:
Just change this line:
xmlns:map="http://schemas.android.com/apk/res-auto"
with this:
xmlns:map="http://schemas.android.com/tools"
AS I MENTIONED - I'M A NOOB AND MAYBE MY SOLUTION GOT SOME SIDE EFFECTS SO PLEASE LET ME KNOW IF SO (although everything seemed to be working fine by so far...).
That's my working map layout with a button on the top and no errors:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/tools"
tools:context="com.maverickrider.myapp.inviteActivity.MapsActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/purpura_E51B4A">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
map:cameraTargetLat="51.513259"
map:cameraTargetLng="-0.129147"
map:cameraTilt="30"
map:cameraZoom="13"
/>
<Button
android:id="#+id/startActivityButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:onClick="cokolwiek"
android:text="Baton z dupy"
android:layout_alignParentBottom="true"
/>
</FrameLayout >
I had this problem as well. I did Project/Clean and the error went away and it works fine now. This assumes that the map namespace is properly defined above where it's being used.
I'm running 0.5.8 and the XML viewer is underlining the attrs with map: - however the app is building fine. YMMMV.
I'm sorry if this question's been asked already but I wasn't able to find any answers. Here's some background context:
I was testing my app on my Nexus 4 to fix some minor bugs. However, just as eclipse was launching it, there was a powercut in the area, switching my computer off. Eventually, once the power restored, I thought I would set a font by .setTypeFace() before running my app again but this made my app crash when I did run it. So after fiddling around with the code and finding no fix, I decided to get rid of the whole font and just run the app with the bug fix. However, this made my app look like this.
Now on eclipse, the graphical layout is showing this. My app before today was showing like the graphical layout perfectly fine. No errors are showing up on eclipse.
Why has this happened and how do I fix this? Could I have corrupted the whole file?
Thanks.
EDIT: the xml file:
<?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:background="#drawable/testbg"
android:orientation="vertical"
android:weightSum="100" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33" >
---- bunch of textviews ----
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="57" >
---- More Textviews ----
</RelativeLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="horizontal"
android:weightSum="3" >
---- three buttons ----
</LinearLayout>
</LinearLayout>
I finally figured it out - it was the background. I must've obviously messed up the 9.png somewhere because it fixed itself once I got rid of the background.
Normally this happens with my apps when i change the font , some fonts appears like this in the layouts , some play around i use is adding a character or a dot after tab space , and it works , however double check the font issue again ,try to set the font again or to set another font.