Questions tagged [android-xml]

Android projects use XML in several ways: defining the project and components, building layouts, defining animations, creating menus and specifying resources (static and dynamic) for the project.

Introduction

In addition to Java code, Android projects (and their developers) have the ability to utilize XML to perform many standard tasks. Some XML usage is required, such as the definition of the projects and its components. Much of XML's usage is optional, making many common tasks easier. The Android XML schema is highly flexible and may be used in combination with code, exclusively, or not at all. Below is a list of common usage of XML:

  • Manifest - definition of the project
  • Layout - creation of partial or complete layouts for Activities, Dialogs, and Widgets
  • Colors - Constant color values used throughout the project
  • Style & Themes - application of custom standardized looks of Views
  • Animations - Standardized animations that may be applied to Views.
  • Drawables - Some specialized icons and graphics that may not be created wholely with an image editor. (StateDrawables, TranstionDrawables, Shapes and VectorGraphics)
  • Menu - A resource used to aid in standardized menus for an Activity
  • Integers, Strings, and Arrays - Constants used by the Application as resources.

AndroidManifest.xml

This file is a core component for every Android project. In order for nearly every component to work, it must be declared in the Manifest. The Manifest may affect everything from type of instancing to meta-data, even security restrictions. A comprehensive resource for the AndroidManifest.xml file exists at the Android Developers Dev Guide. Questions regarding the Android Manifest should use the android-manifest tag instead.

Android Layout XML

Android Layout may be partially or fully defined in XML to modularize presentation and limit code. The capabilities of Android Layout XML are quite extensive, allowing nearly every aspect of presentation to be managed in pure XML. Questions regarding layout should also use the android-layout tag.

Resources (Integers, Arrays, Strings, Colors, Styles, Themes, Menus)

One of the predominant uses of Android XML is to define resources that may be used by the entire application code base, similar to that of constants. Since so much of resource definition has been standardized throughout software development as a whole, XML provides a way to define these without having to manually generate much code that puts these to use. Before posting a question, it is best to make sure it is not covered by these documents:

Drawables and Animations

Android allows you to define special drawables or animations via XML. The ability to dynamically generate graphics and animation can significantly reduce code and further separate presentation from implementation. Questions regarding either of these should also utilize the animation tag or drawable tag respectively.

3013 questions
1
vote
1 answer

Undesired FrameLayout Stretch to Wrap All Children's Heights (Instead of Respecting Just One Child's Height)

Basically, I am using a popular tactic to center a background image for a LinearLayout by wrapping it in a FrameLayout and adding an ImageView that uses fill_parent before the LinearLayout. However, when I add a ScrollView in the game, everything…
1
vote
1 answer

XML tags in Android- Is there a reference

I'm doing an Android XML GUI layout: 1)I want the inputType to be a…
CocoNess
  • 4,213
  • 4
  • 26
  • 43
1
vote
2 answers

Make RelativeLayout non selectable

I've developed a login page and have created a custom xml layout for a loading screen. Everything in the layout for the loading screen is contained within a RelativeLayout. When the user hits the sign in button, the loading screen gets placed over…
Romes
  • 3,088
  • 5
  • 37
  • 52
1
vote
0 answers

"ActivityObject" or many objects?

My issue is this: I am making a few activity screens that requires the use of some parts of information from all 3 Xml files. The problem comes when after parsing the xml's, I am stumped on what kind of object to store them with, to reduce the…
1
vote
1 answer

R. showing an error when xml again

I am doing the android development with travis thenewboston on youtube. I'm getting an error in some lines with R. It was all working fine until i added my R.id.Exit and did a project clean then all went haywire. None of my xml files are throwing…
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
1
vote
1 answer

Inflate a view between elements in a view (Android XML)

I want to inflate some views but have a button at bottom of the view. I already know how to dynamically inflate views and then inflate the button below the other inflated views. However, when there are only a few inflated views (causing the…
Goku
  • 1,565
  • 1
  • 29
  • 62
1
vote
2 answers

Android: ListView and TabWidget: The ListView goes over the TabWidget

I am using the TabWidget in my android project and I have a listView and a FrameLayout in the view. The problem is that when the ListView is higher than the screen height, the Tabs are invisible because the listview goes over the tabs. I don't know…
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
1
vote
1 answer

Can XmlPullParser be configured to NOT ignore whitespace?

I'm using XmlPullParser to parse some custom XML. I open the XML file like this... XmlPullParser xpp = activity.getResources().getXml(R.xml.myXML); And later I read the following XML node #### using the code String str = ""; if(…
David Welch
  • 369
  • 1
  • 9
1
vote
1 answer

Error paring XML with apostrophy as '

I'm trying to parse an XML feed using DOM. When a node looks like this: 'Star Wars' May the force live the returned XML is only ' and then the parser continues on to the next node. Here's how I'm parsing it: NodeList list…
user123321
  • 12,593
  • 11
  • 52
  • 63
1
vote
2 answers

Error inflating class fragment from the xml

I found few similar questions here, but the proposed answers do not suit me. So the error is : 08-13 14:40:10.723: E/AndroidRuntime(630): java.lang.RuntimeException: Unable to start activity…
Denys
  • 4,287
  • 8
  • 50
  • 80
1
vote
1 answer

Android- XML parser not returning full value from XML

The problem is, when i try to get value from xml below The Return of Toastmasters http://www.younginnovations.com.np/blogs/anjan/2012/06/return-toastmasters <p>As the title implies, it was…
user98239820
  • 1,411
  • 2
  • 16
  • 30
1
vote
0 answers

Can't make button react to onClick

I have these 2 buttons inside an Activity. The backBtn works fine, but nothing happens when I click on the reg_country button. Any idea of what's going on? [EDIT] Edited with some log, onClick just does't executes when I touch the button. 08-10…
Lucas Jota
  • 1,863
  • 4
  • 24
  • 43
1
vote
1 answer

Inflating UI from XML

I have a very basic program which displays a standard Textview and a extended Textview. The extended ones are to be inflated into the main Layout. Now every time I add a new extended textview, it appears fine however I also want some gap between…
1
vote
1 answer

Can Android XML input "@"?

I want to hard code a string resource with an email syntax like ABC@gmail.com. But, eclipse pop up an error to say that "@" cannot be included. How can '@' include in the string resource. Thanks you.
King Wu
  • 387
  • 1
  • 8
  • 22
1
vote
2 answers

ExpatParser$ParseException when parsing a local xml file using SAX parser in android

I'm trying to learn how to parse an xml file using SAX parser in Android. I placed an example xml file as such: res/xml/example.xml Here is the xml code
Mohamed Heiba
  • 1,813
  • 4
  • 38
  • 67
1 2 3
99
100