Tag: xml

Why do I get white space on top and on the bottom of my ImageView in my RelativeLayout?

I am using a relativelayout to overlay to images. On all screen sizes so far that I have tested (from 2.7 to 10.1 inch) I always get white space on top of my image. In my IDE I always see that my relativelayout is causing the extra space on top and on the bottom of […]

Android arrange layout with height in percentage

I am very new to android and practicing. I am trying to design a screen. With will contain a background image and a floating container with sliding menus. ( For more details please find the attached image ) My layout consists of a background image, a container with some icons will float at the bottom, […]

How to set XML fullscreen in Android

How do I create a full screen mode in XML irregardless of how small what contents are in it? Here’s my “show.xml” code: <LinearLayout android:orientation=”vertical” android:layout_height=”wrap_content” android:layout_width=”fill_parent” android:layout_gravity=”center”> <Button android:id=”@+id/ok_btn” android:layout_height=”fill_parent” android:layout_width=”fill_parent” android:typeface=”sans” android:text=”ok”></Button> </LinearLayout> I want to display it like another full screen page, with black background, like a main.xml. In this case, its […]

Convert XML to JSON object in Android

I have an XML string as shown below: <s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/”><s:Body><Response xmlns=”http://tempuri.org/”><UserResult><Users xmlns=””><User> <Message>Success</Message> <UserId>213213213</UserId> <FullName>Abc</FullName> <Roles> <Role> <RoleId>23232333</RoleId> <RoleName>Salesperson</RoleName> </Role> </Roles> </User> </Users> </UserResult></Response> </s:Body> </s:Envelope> Is it possible to convert XML to JSON?

Android TextView SingleLine field hides long text

I have a TextView which sits on the left side of the screen and is set with gravity=”right” and it is set with SingleLine = “true.” If by some chance the text in this view gets too long I want it to simply disappear off the left hand side of the view. I thought the […]

How to show only top and bottom border

This is my XML code which works fine, the only problem is it’s showing border on all four sides while I want only to show border on the top and on the bottom only. How can I do that? <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <solid android:color=”#FFFFFF” /> <stroke android:width=”3dip” android:color=”#B1BCBE” /> <padding android:bottom=”0dip” android:left=”0dip” […]

Scaling a drawable inside a button?

Currently my drawable just scales to it’s normal size, I want it to fit inside my button. Here’s a picture of how it looks now: Here is the xml for the button: <LinearLayout android:layout_width=”wrap_content” android:id=”@+id/linearLayout2″ android:layout_height=”40dp” android:layout_weight=”0.4″ android:gravity=”right|center_vertical” android:paddingRight=”5dp”> <Button android:id=”@+id/button1″ android:background=”@drawable/refresh” android:layout_height=”25dp” android:layout_width=”150dp” android:text=”@string/buttonSearchAgain” android:drawableRight=”@drawable/refresh_48″></Button> </LinearLayout> So I want it to look like this: […]

Trying to build a correct SOAP Request

I have been struggling for hours trying to build the correct SOAP request using ksoap2 for Android with no luck. The ideal request looks like this: <?xml version=”1.0″ encoding=”utf-8″?> <soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”> <soap:Header> <AuthorizationToken xmlns=”http://www.avectra.com/2005/”> <Token>string</Token> </AuthorizationToken> </soap:Header> <soap:Body> <ExecuteMethod xmlns=”http://www.avectra.com/2005/”> <serviceName>string</serviceName> <methodName>string</methodName> <parameters> <Parameter> <Name>string</Name> <Value>string</Value> </Parameter> </parameters> </ExecuteMethod> </soap:Body> </soap:Envelope> I am […]

What is the best practice for naming the id of XML Element in Android?

I am not sure if anyone was bugged with this issue before, but it is one big pain for me. How do you give an id to xml element in android? Right now, I set the id with the pattern [activity/fragment name][element type][specific name]. For example, if I had an EditText to keep an email […]

Setting Button Text Color with a Style

I have not been able to set the text color of a Button using a predefined style. I must be missing something simple. For example, I have a button: <Button android:id=”@+id/calculate_button” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”@string/calculate” android:background=”@drawable/rounded_bottom_shape” android:padding=”5dp” android:textAppearance=”@style/CalcResultStyle”> </Button> And the corresponding style is: <style name=”CalcResultStyle”> <item name=”android:textSize”>12sp</item> <item name=”android:textColor”>#FFF</item> </style> The size portion works fine, […]

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