Tag: xml

Escape multiple “%” characters in Android

In <string-array name=”versions”> I have this beast of an entry (boiled down to a reasonable minimum to reproduce the effect): <item>100% foo 40%bar</item> which produces these errors: Multiple annotations found at this line: – error: Multiple substitutions specified in non-positional format; did you mean to add the formatted=”false” attribute? – error: Found tag </item> where […]

Add drop shadow effects to EditText Field

I am trying to design an EditText Field having Shadows (bottom and right side) like this tried googling & hunted many SO discussions but all are for TextView not EditText. This is my code adding shadow to Input Text but not to TextField <EditText android:id=”@+id/txtpin” android:maxLength=”4″ android:layout_marginLeft=”10dp” android:layout_height=”37dp” android:gravity=”center_horizontal” android:inputType=”textPassword” android:longClickable=”false” android:layout_width=”160dp” android:shadowColor=”@color/Black” android:shadowDx=”1.2″ android:shadowDy=”1.2″ […]

Good Tools To Develop a GUI in Android?

I would like to know if there exists a good tool to implement a design in Android like tools to make easy to implement and that can generate XML Thanks for your help.

Using attributes from API level beyond minSdkVersion

I am new to Android development and am wondering what happens if you use attributes on XML tags from an API level greater than your minSdkVersion. For example having: <uses-sdk android:minSdkVersion=”9″ android:targetSdkVersion=”20″ /> And then using this: <activity android:logo=”@drawable/iconwhatever”></activity> The “android:logo” attribute is from API level 11. In Android Studio it gives the following error, […]

Android set XML shape as drawable programmatically

Hello I have a drawable myshape.xml, it contains a <shape> and I cannot set an android:id to shapes. In my code I want to set the background of a view to this file using catAll.setBackgroundDrawable(getResources().getDrawable(R.id……???)); where myshape.xml does not show up in my R file because it has no id. and I cannot set id […]

How can I define a fragment's layout from XML?

I’m trying to define a fragment’s layout in XML in the same way that I defined the layout of my view. Is this possible? I tried several things, but none of them seem to work. My activity layout looks as follows (main.xml): <?xml version=”1.0″ encoding=”utf-8″?> <ListView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” > <fragment xmlns:android=”http://schemas.android.com/apk/res/android” android:name=”full.lommeregner.Lommeregnerrv2Activity” android:layout_width=”match_parent” android:layout_height=”match_parent” […]

With SAX Parser, get an attribute's value

I am parsing XML from the web using Android. The code below shows a sample of the XML. The problem I’m having is I can’t get the string value of the item tag. When I use name = attributes.getQName(i); it outputs the name, not the value of the attribute. <weatherdata> <timetags> <item name=”date”> <value>20/04/2012</value> <unit/> […]

Change color of Switch in Android

I’m trying to change the color of my switch in Android. I realize that I will need new 9patches. I went over to http://android-holo-colors.com/ and selected my color and selected (Switch Jelly Bean). To use Switch Jelly Bean I had to use: https://github.com/BoD/android-switch-backport. To import it into my project I had to add: <item name=”switchStyle”>@style/Widget.Holo.CompoundButton.Switch</item> […]

Using the colors for the new Material design theme in Android

I was in the process of designing an Android application and decided to try out the new Material theme. I found all of the available color schemes for the new theme online, but I was unable to find a corresponding .xml file that has all of the colors in the color palette. Does anyone know […]

How to get gravity 'bottom' working on a drawable in xml

I have a simple aim. I want a light grey background on my FrameLayout with a black dividing line underneath it (only undernearth, not all around). So far I have this: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item> <shape android:shape=”rectangle” android:gravity=”center”> <solid android:color=”#EEEEEE” /> </shape> </item> <item> <shape android:shape=”line” android:gravity=”bottom” > <stroke android:width=”1dip” android:color=”#010101″/> </shape> </item> […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.