I am new to Android Development and trying to create a sample application. Can anyone tell me whats wrong with following layout (activity_sample.xml)? -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/app_name"
tools:context=".SampleActivity" />
</LinearLayout>
On Build, I am getting following error -
error: Error parsing XML: unbound prefix activity_sample.xml /Sample/res/layout line 4 Android AAPT Problem
You haven't declared the tools prefix in your XML. Try using:
<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:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/app_name"
tools:context=".SampleActivity" />
</LinearLayout>
Related
I am working on android application, in which i am getting an error of Zero Exception. I am also not able to see my xml display on editor but it is working on device or emulator. Kindly please guide me what should i do for this error. My XML code is given below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg"
android:gravity="center_vertical"
android:orientation="horizontal" >
<com.zhy.view.CircleMenuLayout
android:id="#+id/id_menulayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="100dp"
android:background="#drawable/circle_bg" >
<RelativeLayout
android:id="#+id/id_circle_menu_item_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="104.0dip"
android:layout_height="104.0dip"
android:layout_centerInParent="true"
android:background="#drawable/turnplate_center_unlogin" />
<ImageView
android:layout_width="116.0dip"
android:layout_height="116.0dip"
android:layout_centerInParent="true"
android:background="#drawable/turnplate_mask_unlogin_normal" />
</RelativeLayout>
</com.zhy.view.CircleMenuLayout>
</LinearLayout>
I was building away with my application and all of the suden i got this error:
No resource identifier found for attribute 'linearLayoutOrientation' in package 'android'
I know where the error is created but i do not know how i can fix this. Can somone take a look and tell me what i am doeing wrong. I am building the application in Xamarin Studio.
<?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:background="#ffd8d8d8">
<TextView
android:id="#+id/Heading"
android:text="."
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff0f62ae"
android:textSize="30dp"
android:textColor="#FFFFFFFF"
android:textStyle="bold"
android:padding="15dp" />
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:height="40dp"
android:minHeight="40dp"
android:layout_marginRight="0.0dp"
android:linearLayoutOrientation="vertical" />
<View
android:layout_width="fill_parent"
android:layout_height="4.0dp"
android:id="#+id/separator"
android:visibility="visible"
android:background="#ff0b487f" />
<ListView
android:id="#+id/dataListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#ff0f62ae" />
</LinearLayout>
Thanks in advance
remove
android:linearLayoutOrientation="vertical"
from edittext tag
and add
android:orientation="vertical"
in LinearLayout tag
remove android:linearLayoutOrientation="vertical"from editText from layout as you have provided it solve your issue in this context
Hi i have made this xml file but it is throwing some error : Incorrect line ending: found carriage return (\r) without corresponding newline (\n)
Here is my XML 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"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/help_new_session"
android:layout_above="#+id/buttonHideNewSessionHelp"
/>
<Button
android:id="#+id/buttonHideNewSessionHelp"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:onClick="onButtonClick"
android:text="Hide" />
</RelativeLayout>
</LinearLayout>
The below process will resolve your issue.
Open layout file
Ctrl+Shift+F
Save the layout file and close it.
Delete any .out files the builder might have created(you can see .out files below the original layout file).
Clean project.
Try this layout Now
<?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"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/help_new_session"
android:layout_above="#+id/buttonHideNewSessionHelp"/>
<Button
android:id="#+id/buttonHideNewSessionHelp"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:onClick="onButtonClick"
android:text="Hide" />
</RelativeLayout>
</LinearLayout>
It is looking perfect
I use the same code of your not giving any problem to me.Select complete xml and use ctrl+i i will align and clean the project once
I saw so many answer of this question here but not one solve my problem. I am trying to make a tab layout I which there is text is text view in table layout and below table layout I want to add map. and I'm trying to do this but not get the result.
my error is
Failed to find style 'mapViewStylr' in current theme
after adding the MapView I got this error. and when I run the code on Nexus one and try to open the layout in which I added the MapView then the application Unfortunately stopped.
here is my layout code
<?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="vertical"
android:background="#android:color/white"
>
<ScrollView
android:id="#+id/info_tab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="#+id/venuinfolayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#android:color/white" >
<TableLayout
android:id="#+id/venuetable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true"
android:weightSum="2"
>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/venueaddress"
android:text="Address:"
android:textColor="#android:color/black"
android:padding="6dip"
android:textStyle="bold"
android:textSize="20dip" />
<TextView
android:id="#+id/venueaddress_details"
android:layout_height="wrap_content"
android:layout_width="180dip"
android:singleLine="false"
android:layout_toRightOf="#id/venueaddress"
android:textColor="#android:color/black"
android:text="text"
android:layout_marginLeft="10dip"
android:padding="6dip"
android:textSize="15dip"
/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/venuephone"
android:layout_below="#id/venueaddress"
android:text="Phone:"
android:textColor="#android:color/black"
android:padding="6dip"
android:textStyle="bold"
android:textSize="20dip" />
<TextView
android:id="#+id/venuephone_details"
android:layout_below="#id/venueaddress_details"
android:layout_toRightOf="#id/venuephone"
android:text="number"
android:textColor="#android:color/black"
android:layout_marginLeft="10dip"
android:padding="6dip"
android:textSize="15dip" />
</TableRow>
</TableLayout>
<com.google.android.maps.MapView
android:id="#+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/venuetable"
android:clickable="true"
android:apiKey="AIzaSyAvWazTUUQr88b_UqQvB4k5rPAtOhlxTFA" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
//try this it may help you
Add this into your manifest file
<uses-library android:name="com.google.android.maps" />
I had the same problem when I try to build a simple app, following the Android MapView tutorial.
The app showed this exception in AVD for the file file main.xml:
Failed to find style 'mapViewStyle' in current theme
At last I found that there is a mistake in file AndroidManifest.xml:
The element should be a child of the element, not immediately within .
Hope this was any help to you.
OR
look Here
I am a beginner coder trying to learn how to make android apps. I am using these tutorials and I guess I have ran into an error.
Here is my text.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="25dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/etCommands"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Type a command"
android:password="true" />
<LinearLayout
android:weightSum="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<Button
android:layout_weight="20"
android:id="#+id/Bresults"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
<ToggleButton
android:layout_weight="80"
android:id="#+id/tbPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="ToggleButton"
android:checked="true" />
</LinearLayout>
<TextView
android:id="#+id/tvresults"
android:paddingBottom="10dp"
android:checked="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="invalid" />
</LinearLayout>
I am getting an error next to where it says button. The error says:
Multiple annotations found at this line: - Element type "LinearLayout" must be followed by either attribute specifications, ">" or "/>". - error:error parsing XML:not well-formed (invalid token)"
You need to close the tag on your second Linear Layout >
<LinearLayout
android:weightSum="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <!-- here -->
The colorcoding in your post already highlights the issue. You forgot the > after the LinearLayout opening tag.
The IDE is complaining that your xml is not well-formed. If the IDE's errors are not clear enough, you try an online validator such as http://www.xmlvalidation.com/ .