Array
(
    [0] => WP_Term Object
        (
            [term_id] => 21
            [name] => Android
            [slug] => android
            [term_group] => 0
            [term_taxonomy_id] => 21
            [taxonomy] => category
            [description] => 
            [parent] => 0
            [count] => 104
            [filter] => raw
            [cat_ID] => 21
            [category_count] => 104
            [category_description] => 
            [cat_name] => Android
            [category_nicename] => android
            [category_parent] => 0
        )

    [1] => WP_Term Object
        (
            [term_id] => 85
            [name] => Android Projects
            [slug] => android-projects
            [term_group] => 0
            [term_taxonomy_id] => 85
            [taxonomy] => category
            [description] => 
            [parent] => 0
            [count] => 39
            [filter] => raw
            [cat_ID] => 85
            [category_count] => 39
            [category_description] => 
            [cat_name] => Android Projects
            [category_nicename] => android-projects
            [category_parent] => 0
        )

    [2] => WP_Term Object
        (
            [term_id] => 84
            [name] => Android Source Code
            [slug] => android-source-code
            [term_group] => 0
            [term_taxonomy_id] => 84
            [taxonomy] => category
            [description] => 
            [parent] => 0
            [count] => 40
            [filter] => raw
            [cat_ID] => 84
            [category_count] => 40
            [category_description] => 
            [cat_name] => Android Source Code
            [category_nicename] => android-source-code
            [category_parent] => 0
        )

)
///////////

json2view : How to change properties of Android UI

0
100
How to Make dynamic Android View using json2view library
How to Make dynamic Android View using json2view library

As we discuss in my previous article about json2view which is a simple library that can convert a compatible JSON file to an Android view so you can load dynamically the view in your Android app without the need to update the APK.

You can check installation and implementation of json2view Android library.

Let come with example of json2view Android library and in this tutorial we studying how to change properties of Android ui using json2view library.

Xml 2 JSON Examples

Changing Properties

change properties of Android UI
change properties of Android UI

Using json2view to change text color, background color and position of a view

before

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"`* 1. > 
***
`
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_margin="10dp"
        android:text="Rate us" />

</RelativeLayout>
{
  "views": [{
    "views": [],
    "properties": [{
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "true",
      "type": "BOOLEAN",
      "name": "layout_alignParentLeft"
    },
    {
      "value": "true",
      "type": "BOOLEAN",
      "name": "layout_alignParentBottom"
    },
    {
      "value": "10dp",
      "type": "dimen",
      "name": "layout_margin"
    },
    {
      "value": "Rate us",
      "type": "string",
      "name": "text"
    }],
    "widget": "Button"
  }],
  "properties": [{
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_width"
  },
  {
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_height"
  }],
  "widget": "RelativeLayout"
}

after

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:textColor="#ef7047"
        android:background="#ffffff"
        android:layout_margin="10dp"
        android:text="Rate us" />

</RelativeLayout>
{
  "views": [{
    "views": [],
    "properties": [{
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "true",
      "type": "BOOLEAN",
      "name": "layout_alignParentRight"
    },
    {
      "value": "true",
      "type": "BOOLEAN",
      "name": "layout_alignParentTop"
    },
    {
      "value": "#ef7047",
      "type": "color",
      "name": "textColor"
    },
    {
      "value": "#ffffff",
      "type": "color",
      "name": "background"
    },
    {
      "value": "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA7wBwAEfvjlcSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wEcDTMeDq8OzQAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAF6UlEQVRIx7WXW49c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UAIpJPoSmk62Hod9YF0ZR7sAzQJJHEY+T+eFHzGQYz68/nO2um3KYhNv5ziZYytwukpVW8oU6K32sJd+gj03YI5FI/QNICWopw4OQ1wS/mBkgDFUEdoGKEpO5iVi2yxKpe9uoLGHmA7iE2rHeIUU1pnPu3Ty28DzeHpEWY6radaml0ZLTpXMyIIIJNMc//7uu+ztvI83gs+Ejo+onlCkKbM4ZRoLgolgcuazXe5N/gLFDJ/AAspSulIjXiJyOrA1AhgyAdEFMr/JIN5l2E50Tc5B3iL1n6Z19uvI6guU5hxFbXDMGPaOuXfwGouDW0iAFEA1NPJoDEgDfDrVOKoSuh44uYmbbbPh52SxpCgKyq0XOX/ph7SH34HZAeODV1ns/5Y0O6CLx5d7VNNduiPwGURNGGlqdL6RylOBq1jjxEOCYv9tDj54g3Zdkg0v0hqOuPS1H9Ne/SqkEQyeZrSxRtrY4ujmH5mOb2PyGSeTf7Py1B1s+xzQaiwSNYr/yKt9cmVZsAZIgdl8TLRCd/Qigyuv4M9/GVaep06BIp1gTY/u4DlM7wLD/pe4t/9P2H6Vu5Nt2ofXGK2dxeCWE9uYBFV9GNWJoLCYHHCcH7N58TJnvvg9GH2fE7tOP5wgJiPLWkRgSqBlW7S2vs3axjdZs/vEnX2qYo+qXGBsH+sUIRCCxYg+xGVGQEsOD3dZ5McMh0O6gyGkDNTz4Ox/Mu4y3p9QljWr65sMBhuoGlICa+3D7a1WCfGA1GgsEOuaU0kOogEvnwKcf+wKjbs/yKTU0GytfQiwKrJ0i0ojh5oaMGMcIv8bOFUlxvv72ZaS2HwTY2xynAoMKNrcFuRj43gfTx7F/y4TpWURYpsHSROCf0yX+X+I07taFSMKomjTaWgSdEk1n0Z1WFIt/NddSpZXHEUM/AeYhwcndizWhAAAAABJRU5ErkJggg==",
      "type": "base64",
      "name": "drawableRight"
    },
    {
      "value": "10dp",
      "type": "dimen",
      "name": "layout_margin"
    },
    {
      "value": "Rate us",
      "type": "string",
      "name": "text"
    }],
    "widget": "Button"
  }],
  "properties": [{
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_width"
  },
  {
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_height"
  }],
  "widget": "RelativeLayout"
}

Next Example :

json2view : How to changes Android layout dynamically

Hope you like this tutorial and if you’ve any problem then comment box is for you.

Share your thoughts

Loading Facebook Comments ...
Loading Disqus Comments ...