Write XML in Android

When we write a XML in android, you can choose difference ways, in this case we recommend XMLSerializer, which is an efficient and maintainable way to parse XML on Android.

Implements an XML serializer supporting both DOM and SAX pretty serializing.

We put this simple line:

            xmlSerializer.setOutput(writer);
            xmlSerializer.startDocument("UTF-8", true);
            xmlSerializer.startTag(null, "doc");

            xmlSerializer.startTag(ns, country);
            xmlSerializer.text(filmObject.getCountry());
            xmlSerializer.endTag(ns, country);

            xmlSerializer.endTag(ns, "doc");
            xmlSerializer.endDocument();
            xmlSerializer.flush();

We made a example with films:

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<doc>
    <film title="Scarface">
        <runningTime>163 min.</runningTime>
        <country>USA</country>
        <director>Brian De Palma</director>
        <cast><name>Al</name>
            <surname>Pacino</surname><name> Steven</name>
            <surname>Bauer</surname><name>Michelle</name><surname>Pfeiffer</surname>
            <name>Mary Elizabeth</name>
            <surname>Mastrantonio</surname>
        </cast>
    </film>
    <film title="Hitman">
        <runningTime>96 min.</runningTime>
        <country>USA</country>
        <director>Aleksander Bach</director>
        <cast><name>Rupert</name>
            <surname>Friend</surname>
            <name>Zachary</name>
            <surname>Quinto</surname>
            <name>Hannah</name>
            <surname>Ware</surname>
            <name>Ciarán</name>
            <surname>Hinds</surname>
        </cast>
    </film>
    <film title="Out of Africa">
        <runningTime>160 min.</runningTime>
        <country>USA</country>
        <director>Sydney Pollack</director>
        <cast>
            <name>Robert</name>
            <surname>Redford</surname>
            <name>Meryl</name>
            <surname>Streep</surname>
            <name>Klaus Maria</name>
            <surname>Brandauer</surname>
            <name>Michael</name>
            <surname>Kitchen</surname>
        </cast>
    </film>
</doc>

In your activity you can put this lines with this films:

public void writeXml(List<Film> films) {


        try {
            FileOutputStream fileOutputStream = new FileOutputStream(mFileOutPut);
            XmlSerializer xmlSerializer = Xml.newSerializer();
            StringWriter writer = new StringWriter();

            xmlSerializer.setOutput(writer);
            xmlSerializer.startDocument("UTF-8", true);
            xmlSerializer.startTag(null, "doc");

            insertFilms(xmlSerializer, films);

            xmlSerializer.endTag(ns, "doc");
            xmlSerializer.endDocument();
            xmlSerializer.flush();
            String dataWrite = writer.toString();
            fileOutputStream.write(dataWrite.getBytes());
            fileOutputStream.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();

        } catch (IllegalArgumentException e) {
            e.printStackTrace();

        } catch (IllegalStateException e) {
            e.printStackTrace();

        } catch (IOException e) {
            e.printStackTrace();

        }


    }

    public void insertFilms(XmlSerializer xmlSerializer, List<Film> films) throws IOException {
        final String film = "film";
        String title = "title";
        String runningTime = "runningTime";
        String country = "country";
        String director = "director";
        String cast = "cast";
        Film filmObject;
        for (int i=0; i<films.size(); i++) {
            filmObject = films.get(i);
            xmlSerializer.startTag(ns, film);
            xmlSerializer.attribute(ns, title, filmObject.getTitle());

            xmlSerializer.startTag(ns, runningTime);
            xmlSerializer.text(filmObject.getRunningTime());
            xmlSerializer.endTag(ns, runningTime);

            xmlSerializer.startTag(ns, country);
            xmlSerializer.text(filmObject.getCountry());
            xmlSerializer.endTag(ns, country);

            xmlSerializer.startTag(ns, director);
            xmlSerializer.text(filmObject.getDirector());
            xmlSerializer.endTag(ns, director);

            xmlSerializer.startTag(ns, cast);
            insertCast(xmlSerializer, filmObject.getCast());
            xmlSerializer.endTag(ns, cast);

            xmlSerializer.endTag(null, film);
        }

    }

    public void insertCast (XmlSerializer xmlSerializer, List<Actor> cast) throws IOException {
        String name = "name";
        String surname = "surname";
        Actor actor;
        for (int i=0; i<cast.size(); i++) {
            actor = cast.get(i);
            xmlSerializer.startTag(null, name);
            xmlSerializer.text(actor.getName());
            xmlSerializer.endTag(null, name);

            xmlSerializer.startTag(null, surname);
            xmlSerializer.text(actor.getSurname());
            xmlSerializer.endTag(null, surname);
        }

    }

Example in GitHub

Read XML in Android

Extensible Markup Language (XML) is a set of rules for encoding documents in machine-readable form. XML is a popular format for sharing data on the internet. Websites that frequently update their content, such as news sites or blogs, often provide an XML feed so that external programs can keep abreast of content changes. Uploading and parsing XML data is a common task for network-connected apps. This lesson explains how to parse XML documents and use their data.

Choose Parser

We recommend XmlPullParser, which is an efficient and maintainable way to parse XML on Android. Historically Android has had two implementations of this interface:

Either choice is fine. The example in this section usesExpatPullParser, via Xml.newPullParser().

Analyze

The first step in parsing a film

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<doc>
	<film title="Scarface">
		<runningTime>163 min.</runningTime>
		<country>USA</country>
		<director>Brian De Palma</director>
		<cast><name>Al</name>
			<surname>Pacino</surname><name> Steven</name>
			<surname>Bauer</surname><name>Michelle</name><surname>Pfeiffer</surname>
			<name>Mary Elizabeth</name>
			<surname>Mastrantonio</surname>
		</cast>
	</film>
	<film title="Hitman">
		<runningTime>96 min.</runningTime>
		<country>USA</country>
		<director>Aleksander Bach</director>
		<cast><name>Rupert</name>
			<surname>Friend</surname>
			<name>Zachary</name>
			<surname>Quinto</surname>
			<name>Hannah</name>
			<surname>Ware</surname>
			<name>Ciarán</name>
			<surname>Hinds</surname>
		</cast>
	</film>
	<film title="Out of Africa">
		<runningTime>160 min.</runningTime>
		<country>USA</country>
		<director>Sydney Pollack</director>
		<cast>
			<name>Robert</name>
			<surname>Redford</surname>
			<name>Meryl</name>
			<surname>Streep</surname>
			<name>Klaus Maria</name>
			<surname>Brandauer</surname>
			<name>Michael</name>
			<surname>Kitchen</surname>
		</cast>
	</film>
</doc>

The readFilm() method does the actual work of processing the feed. It looks for elements tagged “entry” as a starting point for recursively processing the feed. If a tag isn’t an entry tag, it skips it. Once the whole feed has been recursively processed, readFilm() returns a List containing the entries (including nested data members) it extracted from the feed. This List is then returned by the parser.

public void readFilm() {
        try {

            InputStream inputStream = new FileInputStream(mFileOutPut);
            XmlPullParser parser = Xml.newPullParser();
            parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
            parser.setInput(inputStream, null);
            parser.nextTag();
            List<Film> filmsList =  readDoc(parser);

            ListAdapter adapter = new ListAdapter(filmsList, this);
            mListView.setAdapter(adapter);

            inputStream.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public List<Film> readDoc(XmlPullParser parser) throws XmlPullParserException, IOException {

        List<Film> list = new ArrayList<Film>();
        parser.require(XmlPullParser.START_TAG, ns, "doc");

        while (parser.next() != XmlPullParser.END_TAG) {
            list.add(readFilms(parser));
        }
        return list;
    }

    // Parses the contents of an film. If it encounters a title, runningTime, country, or director, hands them off
// to their respective "read" methods for processing. Otherwise, skips the tag.
    private Film readFilms(XmlPullParser parser) throws XmlPullParserException, IOException {
        parser.require(XmlPullParser.START_TAG, ns, "film");
        String title = null;

        for(int x=0; x<parser.getAttributeCount(); x++) {
            if (parser.getAttributeName(x).equals("title")) {
                title = parser.getAttributeValue(x);
            }
        }

        String runningTime = null;
        String country = null;
        String director = null;
        List<Actor> cast = new ArrayList<Actor>();

        while (parser.next() != XmlPullParser.END_TAG) {
            if (parser.getEventType() != XmlPullParser.START_TAG) {
                continue;
            }
            String name = parser.getName();
            if (name.equals("runningTime")) {
                runningTime = readRunningTime(parser);
            } else if (name.equals("country")) {
                country = readCountry(parser);
            } else if (name.equals("director")) {
                director = readDirector(parser);
            } else if (name.equals("cast")) {
                cast = readCast(parser);
            } else {
                skip(parser);
            }
        }
        return new Film( title, runningTime, country, director, cast);
    }

    private String readRunningTime(XmlPullParser parser) throws IOException, XmlPullParserException {
        parser.require(XmlPullParser.START_TAG, ns, "runningTime");
        String runningTime = readText(parser);
        parser.require(XmlPullParser.END_TAG, ns, "runningTime");
        return runningTime;
    }

    private String readCountry(XmlPullParser parser) throws IOException, XmlPullParserException {
        parser.require(XmlPullParser.START_TAG, ns, "country");
        String country = readText(parser);
        parser.require(XmlPullParser.END_TAG, ns, "country");
        return country;
    }

    private String readDirector(XmlPullParser parser) throws IOException, XmlPullParserException {
        parser.require(XmlPullParser.START_TAG, ns, "director");
        String director = readText(parser);
        parser.require(XmlPullParser.END_TAG, ns, "director");
        return director;
    }

    private List<Actor> readCast(XmlPullParser parser) throws IOException, XmlPullParserException {
        List<Actor> listActor= new ArrayList<Actor>();
        parser.require(XmlPullParser.START_TAG, ns, "cast");

        String nameActor = null;
        String surnameActor = null;

        while (parser.next() != XmlPullParser.END_TAG) {
            if (parser.getEventType() != XmlPullParser.START_TAG) {
                continue;
            }
            String nameParser = parser.getName();
            if (nameParser.equals("name")) {
                nameActor = readNameActor(parser);
            } else if(nameParser.equals("surname")) {
                surnameActor = readSurnameActor(parser);
                listActor.add(new Actor(nameActor, surnameActor));
            } else {
                skip(parser);
            }

        }
        return listActor;
    }

    private String readNameActor(XmlPullParser parser) throws IOException, XmlPullParserException {
        parser.require(XmlPullParser.START_TAG, ns, "name");
        String nameActor = readText(parser);
        parser.require(XmlPullParser.END_TAG, ns, "name");
        return nameActor;
    }

    private String readSurnameActor(XmlPullParser parser) throws IOException, XmlPullParserException {
        parser.require(XmlPullParser.START_TAG, ns, "surname");
        String surnameActor = readText(parser);
        parser.require(XmlPullParser.END_TAG, ns, "surname");
        return  surnameActor;
    }

    // For the tags title and runningTime, country, director their text values.
    private String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
        String result = "";
        if (parser.next() == XmlPullParser.TEXT) {
            result = parser.getText();
            parser.nextTag();
        }
        return result;
    }
    private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            throw new IllegalStateException();
        }
        int depth = 1;
        while (depth != 0) {
            switch (parser.next()) {
                case XmlPullParser.END_TAG:
                    depth--;
                    break;
                case XmlPullParser.START_TAG:
                    depth++;
                    break;
            }
        }
    }

Example in GitHub

Percentage of screen in android

For doing percentage of screen in android, we use PercentRelativeLayout:

Subclass of RelativeLayout that supports percentage based dimensions and margins. You can specify dimension or a margin of child by using attributes with “Percent” suffix.

The attributes that you can use are:

  • layout_widthPercent
  • layout_heightPercent
  • layout_marginPercent
  • layout_marginLeftPercent
  • layout_marginTopPercent
  • layout_marginRightPercent
  • layout_marginBottomPercent
  • layout_marginStartPercent
  • layout_marginEndPercent
  • layout_aspectRatio

In our dependencies

compile 'com.android.support:percent:22.2.0'

Follow this example:

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.thedeveloperworldisyours.percentrelativelayouts.MainActivity">
 
    <TextView
        android:id="@+id/activity_main_text_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerVertical="true"
        android:background="@android:color/darker_gray"
        android:gravity="center"
        android:text="width 69%"
        app:layout_heightPercent="10%"
        app:layout_marginLeftPercent="4%"
        app:layout_widthPercent="69%" />
 
    <TextView
        android:id="@+id/activity_main_second_text_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/activity_main_text_view"
        android:background="@android:color/holo_red_dark"
        android:gravity="center"
        android:text="width 23%"
        app:layout_heightPercent="10%"
        app:layout_marginRightPercent="4%"
        app:layout_widthPercent="23%" />
</android.support.percent.PercentRelativeLayout>

We can see a big example:
null

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/activity_calculator_black_transparent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingTop="90dp"
    android:weightSum="5"
    tools:context="com.thedeveloperworldisyours.unitconverterpro.calculator.CalculatorActivity">

    <View
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerVertical="true"
        android:background="@drawable/calculator_background"
        app:layout_heightPercent="53%"
        app:layout_marginLeftPercent="2%"
        app:layout_marginRightPercent="2%"
        app:layout_widthPercent="100%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.AutoResizeTextView
        android:id="@+id/activity_calculator_result"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_above="@+id/activity_calculator_divide"
        android:layout_toLeftOf="@+id/activity_calculator_remove"
        android:background="@drawable/calculator_text"
        android:inputType="text"
        android:maxLines="1"
        android:gravity="end"
        android:paddingRight="12dp"
        android:paddingLeft="12dp"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_marginLeftPercent="4%"
        app:layout_widthPercent="69%" />

    <ImageButton
        android:id="@+id/activity_calculator_remove"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_above="@+id/activity_calculator_divide"
        android:layout_alignParentRight="true"
        android:src="@mipmap/ic_backspace_calculator"
        android:background="@drawable/calculator_remove_button"
        app:layout_heightPercent="10%"
        app:layout_marginRightPercent="4%"
        app:layout_widthPercent="23%" />

    <!--fourth-->

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_seven"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_above="@+id/activity_calculator_multiply"
        android:layout_toLeftOf="@+id/activity_calculator_eight"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_seven"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_marginLeftPercent="4%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_eight"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_above="@+id/activity_calculator_multiply"
        android:layout_toLeftOf="@+id/activity_calculator_nine"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_eight"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_nine"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_above="@+id/activity_calculator_multiply"
        android:layout_toLeftOf="@+id/activity_calculator_divide"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_nine"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.BlackplotanButton
        android:id="@+id/activity_calculator_divide"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_above="@+id/activity_calculator_multiply"
        android:layout_alignParentRight="true"
        android:background="@drawable/calculator_operator_button"
        android:text="@string/activity_calculator_divide"
        android:textSize="@dimen/activity_calculator_size_text_operator"
        app:layout_heightPercent="10%"
        app:layout_marginRightPercent="4%"
        app:layout_widthPercent="23%" />

    <!--third-->

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_four"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/activity_calculator_five"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_four"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_marginLeftPercent="4%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_five"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/activity_calculator_six"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_five"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_six"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/activity_calculator_multiply"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_six"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.BlackplotanButton
        android:id="@+id/activity_calculator_multiply"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/calculator_operator_button"
        android:text="@string/activity_calculator_multiply"
        android:textSize="@dimen/activity_calculator_size_text_operator"
        app:layout_heightPercent="10%"
        app:layout_marginRightPercent="4%"
        app:layout_widthPercent="23%" />

    <!--second-->

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_one"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@+id/activity_calculator_multiply"
        android:layout_toLeftOf="@+id/activity_calculator_two"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_one"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_marginLeftPercent="4%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_two"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@+id/activity_calculator_multiply"
        android:layout_toLeftOf="@+id/activity_calculator_three"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_two"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_three"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@+id/activity_calculator_multiply"
        android:layout_toLeftOf="@+id/activity_calculator_diminish"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_three"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.BlackplotanButton
        android:id="@+id/activity_calculator_diminish"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/activity_calculator_multiply"
        android:background="@drawable/calculator_operator_button"
        android:text="@string/activity_calculator_diminish"
        android:textSize="@dimen/activity_calculator_size_text_operator"
        app:layout_heightPercent="10%"
        app:layout_marginRightPercent="4%"
        app:layout_widthPercent="23%" />

    <!--last-->

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_dot"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@+id/activity_calculator_diminish"
        android:layout_toLeftOf="@+id/activity_calculator_zero"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_dot"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_marginLeftPercent="4%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.StarjediButton
        android:id="@+id/activity_calculator_zero"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@+id/activity_calculator_diminish"
        android:layout_toLeftOf="@+id/activity_calculator_equals"
        android:background="@drawable/calculator_button"
        android:text="@string/activity_calculator_zero"
        android:textSize="@dimen/activity_calculator_size_text"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.BlackplotanButton
        android:id="@+id/activity_calculator_equals"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@+id/activity_calculator_diminish"
        android:layout_toLeftOf="@+id/activity_calculator_add"
        android:background="@drawable/calculator_equal_button"
        android:text="@string/activity_calculator_equals"
        android:textSize="@dimen/activity_calculator_size_text_operator"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="23%" />

    <com.thedeveloperworldisyours.unitconverterpro.common.view.BlackplotanButton
        android:id="@+id/activity_calculator_add"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/activity_calculator_diminish"
        android:background="@drawable/calculator_operator_button"
        android:text="@string/activity_calculator_plus"
        android:textSize="@dimen/activity_calculator_size_text_operator"
        app:layout_heightPercent="10%"
        app:layout_marginRightPercent="4%"
        app:layout_widthPercent="23%" />
</android.support.percent.PercentRelativeLayout>