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

NullpointerException when trying to open Android XML file using Android XML Editor in Eclipse Juno

I'm unable to open xml files in Android XML Editor. The error message I get is An error has occurred. See error log for more details. java.lang.NullPointerException On checking error logs :…
Harshal Kshatriya
  • 5,630
  • 11
  • 44
  • 60
1
vote
1 answer

Android: What happens when you change the dimensions of a frameLayout that is set to wrap_content programmatically?

I have a FrameLayout in my application and in the xml file its width and height is set to wrap_content . then I want to change its dimensions programmatically like this : FrameLayout preview = (FrameLayout)…
Navid777
  • 3,591
  • 8
  • 41
  • 69
1
vote
2 answers

How to inflate a view behind another

Forgive me if this is a simple question however I am new to Android Development and this problem has been bugging me. I have a "base" layout file which contains a RelativeLayout and a com.devspark.sidenavigation.SideNavigationView from this…
MattWilliams89
  • 157
  • 1
  • 15
1
vote
1 answer
1
vote
3 answers

android how to make some space between buttons and make white line above each of them

I have two buttons with xml background , i want to keep some space between them, because that are past exactly on each other , also i want to put white line above them , i will give you how i tried but it doesn't work with me
LinCR
  • 391
  • 3
  • 6
  • 14
1
vote
1 answer

Background xml not working

I have buttons and i want to set background xml for them, and when a user press any button i want to change its background , i work like this
1
vote
1 answer

Webview embedded in a Linear Layout won't scroll up and down, only left and right

I have a WebView here so that users of my app can see my web site and I wanted the app version to appear above the Webview so I embedded the WebView tag inside of the LinearLayout but when I ran the project on my device it only scrolls sideways,…
1
vote
1 answer

android is there any way to test xml file on phone

I need to know if there is any way that i can test my xml appearence on phone without running the whole app, i mean just the xml file without any action for anything?
William Kinaan
  • 28,059
  • 20
  • 85
  • 118
1
vote
2 answers

Android: Reference xml from another xml

I'm tryihng to set up a tabs layout in android. Inside the layout with id 'tab1', is there any way that I can reference another xml file? I just don't want to have a huge messy single file. Instead, I would like to reference a different file in each…
Jad
  • 115
  • 2
  • 5
  • 10
1
vote
1 answer

Android Values: Priorities for dimension values if not explicit in bucket

My question is best asked with an example. Let's say you have a 10" Android tablet in landscape. You have not specified a specific value for it's bucket in values-sw720dp-land but YOU DO have values in BOTH values-sw720dp AND values-sw600dp-land…
Geeks On Hugs
  • 1,591
  • 2
  • 18
  • 31
1
vote
1 answer

Android Custom ListView Issue

In my app, I want to do groups of each posts in same post category. Listview doesn't refresh of items counts. Forexample, ".Net" category has 3 posts. Listview has 15 rows. 12 rows are seem empty. How can I refresh listview rows count ? I tried…
1
vote
3 answers

Android XML parsing issues using SAX parser

I am parsing an XML file from assets folder to dump my data into the database. Later on i may fetch this and display it in a text view. But while parsing i am losing some data, ie, if i have some 50 words within the XML tags before parsing, in my…
suresh cheemalamudi
  • 6,190
  • 11
  • 49
  • 67
1
vote
1 answer

Android TextView Programmatically following XML

I currently have this xml: And im trying to convert it to a…
1
vote
1 answer

Providing layout resources for specific screen sizes

In my Eclipse project I currently have the following folders: layout-land layout-large-land layout-sw600dp-land layout-xhdpi-land (I have others too, but the problem right now is for landscape layouts only.) My layout is quite specific: it varies…
gosr
  • 4,593
  • 9
  • 46
  • 82
1
vote
2 answers

ActionBarSherlock mirrod attributes -- when to use "android:" prefix?

When styling ActionBarSherlock I was wondering when I have to use the prefixed attribute, when the non-prefixed attribute, and when both. For example: @style/Widget.Styled.ActionBar