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

Android XML include another xml (non layout)

I have a settings.xml file that I use to set various global variables within my app. I want to be able to create sub xml files that I include in the settings.xml file because depending on the client, I change settings in this file so I want to make…
rplankenhorn
  • 2,075
  • 2
  • 22
  • 32
1
vote
2 answers

Resources NotFoundException for Spinner Android

I have an activity that has a Button. When the Button is clicked it is supposed to open a simple Popup Window that contains a TextView and a Spinner. I have the Popup Window opening up fine. My problem is when I grab a reference to the Spinner it's…
Don
  • 506
  • 2
  • 8
  • 23
1
vote
2 answers

selector item android:state_xxx="false" vs item without state ( default )

What is the difference between these two? According to the documentation the color of…
1
vote
1 answer

Shake animation is "sliding underneath" other widgets android

I am new to animations. I have a spin Animation on a button. The problem is when that button animation is executed the button intersects other buttons in the layout. So during animation the moving button cannot be seen since it is being covered…
Goku
  • 1,565
  • 1
  • 29
  • 62
1
vote
2 answers

Parsing the Xml file which dont have any child nodes

I am new in android development, I want to parse one particular xml file using Dom Parser. The xml structure is something like this.
Nitin Bathija
  • 800
  • 3
  • 12
  • 24
1
vote
0 answers

Change the "P roblem loading widget" text

i would like to know if it's possible to change the dialog of "Problem loading widget" to something like "Widget only working on Portrait Screen". Is that possible? I know that is not the best procedure but i'm trying to support a lot of screens…
1
vote
1 answer

Whats the meaning of having both values and xml directories?

I'm trying to understand why it has been decided to have both values and xml subfolders in the res Android application folder. While I can see the semantics differences between, say, drawables and anim and values (for those hold objects of…
Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
1
vote
3 answers

Loading a layout using ASyncTask in Android

I have an application that loads a dialog with some images specified in the dialog's XML layout. I've read a lot about using images in Android and being careful with the VM budget so I believe that any handling of images with the potential to take…
1
vote
3 answers

add an existing XML layout programatically

I'm going to create a new RelativeLayout with some Text and Image Views programatically and then add it to a parent layout. The question: is it possible to define that layout in XML and then just add it to the parent programatically? Would be a…
Droidman
  • 11,485
  • 17
  • 93
  • 141
1
vote
1 answer

can we parse array element and a value from a android xml array

Can we parse a array element and a value from a android array use in xml layouts. ABC DEF FHI JKL in this array we can parse…
newday
  • 3,842
  • 10
  • 54
  • 79
1
vote
1 answer

android level-list warning that make my app crash

I am new in Android developing, I am reading "For Dummies Android Application Development. All-in-One For Dummies" book and I have encountered a problem. I am trying to create a level-list that contains image for each level, here is the code:
vlio20
  • 8,955
  • 18
  • 95
  • 180
1
vote
1 answer

TableLayout not skipping column 0 when setting android:layout_column = "1"

The xml code on this site: http://www.learn-android.com/2010/01/05/android-layout-tutorial/6/ Gives the table layout shown in the image. http://www.learn-android.com/wp-content/uploads/2010/01/TableLayout.png But if you remove the first table row,…
shim
  • 9,289
  • 12
  • 69
  • 108
1
vote
3 answers

Android: Get Resource ID of custom xml class object by name

I have a custom folder, file and custom XML resource class in my "res" folder. I create some custom objects, which I call: I can access them statically by R.id.someId. However, I need to get the resource…
AlexIIP
  • 2,461
  • 5
  • 29
  • 44
1
vote
3 answers

XML Layout -Button n ot visible after scrolling

I have a XML Layout as follows. I have a TExt View followed by a number of check boxes and then a button. I have enclosed all the check boxes in a Linear Layout and set up a scroll view for that.`I cant view my button after scrolling down, WHat…
chitranna
  • 1,579
  • 6
  • 25
  • 42
1
vote
1 answer

lastfm artist info on android

hey guys I want to display artist info on android so i tried to parse xml but there is odd tag like this " CDATA "before summary of artist so when i run my code i got blank text view I trie for Json but its out of my capacity to write json…
Swap-IOS-Android
  • 4,363
  • 6
  • 49
  • 77
1 2 3
99
100