<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
?xml version="1.0" encoding="utf-8"?>
<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:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
[2013-08-03 09:55:43 - BrendansApp] Error in an XML file: aborting build.
Hello
I have been stuck on this same error for the last two days and nothing I try and do fixes it!
Any ideas on how to fix it?
Thanks!
use <?xml version="1.0" encoding="utf-8"?> you are missing < in ?xml version="1.0" encoding="utf-8"?>
and also it should be first line in your xml code
and also you have two root elements in xml.. there should be single root element
so your code should be
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
Related
I want to place a Relative layout below the custom Zoomview. I don't want the content of Relative Layout to get Zoom. I want a button to be placed at center of that relative layout.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="horizontal"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/twentyfive" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="vertical"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="#string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_centerInParent="true"
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
Never tested code, but hopefully it will work.
Try this -
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="vertical"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_centerHorizontal="true"/> //Or use android:layout_centerInParent="true"
</RelativeLayout>
</LinearLayout>
i'm new to xml, and i can't get past "Multiple Root Tags" error, i`ve read others questions, but nothing seems to work, how can i fix it?
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/Quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="#strig/quantity"
android:textAllCaps="true"
android:textColor="#android:color/darker_gray"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
Your layout should be like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/Quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="#strig/quantity"
android:textAllCaps="true"
android:textColor="#android:color/darker_gray"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Your layout can only have one top-level tag. Yours currently has two (the ConstraintLayout and the LinearLayout). Probably you did not mean to end the ConstraintLayout tag with />; remove the slash and add a closing tag at the bottom of your file.
Bro, your syntax is incorrect
tools:context=".MainActivity" >
Try with this
I am very new to android programming.I have learned css and I want to make margin 0 auto like in css.This is my code:
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.qwe.androidtutorial_1.Layout">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="400dp"
android:orientation="vertical"
android:layout_marginLeft="0dp"
android:gravity="center_horizontal"
android:layout_gravity="center">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/alici"
android:visibility="visible"
android:gravity="center"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/konu"
android:visibility="visible"
android:gravity="center" />
</LinearLayout>
</RelativeLayout>
This is how my design looks like => IMAGE 1
I want to design like this =>IMAGE 2
I want to make this using margin 0 auto(as in css) which makes linearlayout perfectly vertically center in relativelayout.How can I make this?
set
android:gravity="center_horizontal"
in Main RelativeLayout.
You can use below code:
<?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:gravity="center_horizontal">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="400dp"
android:layout_marginTop="20dp"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/alici"
android:visibility="visible"
android:gravity="center"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/konu"
android:visibility="visible"
android:gravity="center" />
</LinearLayout>
</RelativeLayout>
If it is useful, please vote.
i am referring this to implement 3 level expandable list. the code works fine. but my problem is , the items in the child elements not filled the whole area. because of that i cant expand the next child element by clicking on it.(i have to click the exact area which is child element text appeared)
can someone point me, where is the issue?
i have edit my xml view also as android:layout_width="fill_parent"
but didn't worked..
please help me on this.
thank you.
EDIT
HERE THE ALL LAYOUT XML CODES.
ROOT
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:background="#ff5b5b"
android:orientation="vertical" >
<TextView
android:id="#+id/itemRootTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>
PARENT
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:background="#40e0d0"
android:orientation="vertical" >
<TextView
android:id="#+id/itemParentTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>
CHILD
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:background="#839096"
android:orientation="vertical" >
<TextView
android:id="#+id/itemChildTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>
MAIN XML LAYOUT
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ExpandableListView
android:id="#+id/expList"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
>
</ExpandableListView>
</RelativeLayout>
I also encountered this problem with a spinner
I solved it like this
child xml.
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:background="#839096"
android:orientation="vertical" >
<TextView
android:id="#+id/itemChildTitle"
android:layout_width="match_parent" <== and this
android:minWidth="500dp" <=== add this
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>
<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
From this (which is from the android tutorial) I am getting an error that The processing instruction target matching "[xX][mM][lL]" is not allowed (which is on the line starting
Put <?xml version="1.0" encoding="utf-8"?> on the top of the file
Remove xmlns:android="http://schemas.android.com/apk/res/android" from LinearLayout
Put on the top below line#
<?xml version="1.0" encoding="utf-8"?>
And remove from LinearLayout below line#
xmlns:android="http://schemas.android.com/apk/res/android"
For more info refer Stackoverflow Question
I edited your layout. <?xml version="1.0" encoding="utf-8"?> this takes makes the problem:
Below layout correct:
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="horizontal" >
<EditText
android:id="#+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
</RelativeLayout>