json2view : Some important properties and types

Advertisement

In our all previous article we see implementation and their some example of json2view android library.

But here we see some important properties and types of json2view library which you can use in your applications.

Any View

Name Type Example
layout_width dimen {"name":"layout_width", "type":"dimen", "value":"match_parent"}
{"name":"layout_width", "type":"dimen", "value":"250dp"}
{"name":"layout_width", "type":"dimen", "value":"90%"}
layout_height dimen {"name":"layout_width", "type":"dimen", "value":"50dp"}
id ref {"name":"id", "type":"ref", "value":"closeBtn"}
padding_left
padding_right
padding_top
padding_bottom
padding
dimen {"name":"padding", "type":"dimen", "value":"8dp"}
layout_marginLeft
layout_marginRight
layout_marginTop
layout_marginBottom
layout_margin
dimen {"name":"layout_margin", "type":"dimen", "value":"16dp"}
background color {"name":"background", "type":"color", "value":"#00FF00"}
ref {"name":"background", "type":"ref", "value":"drawable_name_in_res_folder"}
base64 {"name":"background", "type":"base64", "value":"BASE64_ENCODE_OF_PNG_IMAGE"}
drawable “`{“name”:”background”, “type”:”drawable”, “value”: {“CORNER”: “10dp
enabled boolean {"name":"enabled", "type":"boolean", "value":"true"}
selected boolean {"name":"selected", "type":"boolean", "value":"t"}
clickable boolean {"name":"clickable", "type":"boolean", "value":"0"}

Text View

Name Type Example
text string {"name":"id", "type":"string", "value":"Hello World!"}
text ref {"name":"id", "type":"ref", "value":"string_id_from_res_string.xml"}
textColor color {"name":"textColor", "type":"color", "value":"0xFF00FF00"}
textSize dimen {"name":"textSize", "type":"textSize", "value":"13sp"}
textStyle integer {"name":"textStyle", "type":"integer", "value":"1"}
Value are Constants in Typeface
  • 0: normal
  • 1: bold
  • 2: italics
  • 3: bold+italics
ellipsize string {"name":"ellipsize", "type":"string", "value":"MIDDLE"}
Enum Value from TextUtils.TruncateAt
maxLines integer {"name":"maxLines", "type":"integer", "value":"3"}
gravity integer {"name":"gravity", "type":"integer", "value":"16"}
Values from Gravity eg 16 for CENTER_VERTICAL
string {"name":"gravity", "type":"string", "value":"CENTER_VERTICAL"}
Constants name from Gravity
drawableTop
drawableBottom
drawableLeft
drawableRight
dimen {"name":"drawableTop", "type":"base64", "value":"Base64EncodedImage"}

Image View

Name Type Example
src ref {"name":"src", "type":"ref", "value":"drawadle_name_from_res"}
base64 {"name":"src", "type":"base64", "value":"Base64EncodedImage"}
scaletype string {"name":"scaletype", "type":"string", "value":"CENTER_CROP"}
Enum Value from ImageView.ScaleType
adjustviewbounds boolean {"name":"adjustviewbounds", "type":"boolean", "value":"f"}

ViewGroup (LinearLayout / RelativeLayout)

Name Type Example
layout_above
layout_alignBaseline
layout_alignBottom
layout_alignEnd
layout_alignLeft
layout_alignRight
layout_alignStart
layout_alignTop
layout_below
layout_toEndof
layout_toLeftof
layout_toRightof
layout_toStartof
ref {"name":"layout_below", "type":"ref", "value":"idOfOtherViewInSameReativeLayout"}
layout_alignParentBottom
layout_alignParentEnd
layout_alignParentLeft
layout_alignParentRight
layout_alignParentStart
layout_alignParentTop
layout_alignWithParentIfMissing
layout_centeHorizontal
layout_centerInParent
layout_centerVertical
boolean {"name":"layout_alignParentBottom", "type":"boolean", "value":"true"}
layout_gravity integer {"name":"layout_gravity", "type":"integer", "value":"16"}
Values from Gravity eg 16 for CENTER_VERTICAL
string {"name":"layout_gravity", "type":"string", "value":"CENTER_VERTICAL"}
Constants name from Gravity
orientation integer {"name":"orientation", "type":"integer", "value":"0"}
  • 0 : horizontal
  • 1 : vertical
string {"name":"orientation", "type":"string", "value":"HORIZONTAL"}
value : "HORIZONTAL" | "VERTICAL"

Generic (experimental)

Name Type Example
Function json { "name": "function", "type": "json", "value": { "function":"setMax", "args":[ {"primitive":"Integer" , "value":"10"} ] } }
to call setMax function with argument 10 of the new created View (eg seekBar.setMax(10) if the property belongs to widget “SeekBar”)

 

Types

Name used in
string eg. the text Value of TextView
integer most used in predefined values
(eg Horizontal == 0 for LinearLayout Orientation)
dimen 12sp, 13dp, 120 (if only number implies pixels),
90% (0.9 * dimension of device screen width)
base64 encoded with base64 image
json custom functionality

 

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

The post json2view : Some important properties and types appeared first on Tell Me How - A Place for Technology Geekier.

Embed this post on your website Embed
 
-->