-
Notifications
You must be signed in to change notification settings - Fork 256
Visual Studio Code智能提示
zhenglibao edited this page Jan 4, 2018
·
15 revisions
- Code -> 首选项 -> 用户代码片段,选择xml
- 在打开的xml.json中粘贴以下内容
{
"UIView":{
"prefix": "view",
"body": [
"<UIView layout=\"$1\" attr=\"$2\">",
"$3",
"</UIView>",
],
"description": "UIView element"
},
"UILabel":{
"prefix": "label",
"body": [
"<UILabel name=\"$1\" layout=\"$2\" attr=\"fontSize:14,color:#ffffff,linesNum:0,text:$3\"/>",
],
"description": "UIView element"
},
"FlexTouchView":{
"prefix": "touch",
"body": [
"<FlexTouchView onPress=\"$1\" layout=\"$2\" attr=\"underlayColor:darkGray,bgColor:lightGray\">",
"$3",
"</FlexTouchView>",
],
"description": "FlexTouchView element"
},
"FlexScrollView":{
"prefix": "scroll",
"body": [
"<FlexScrollView layout=\"flex:1\" attr=\"vertScroll:true\">",
"$2",
"</FlexScrollView>",
],
"description": "FlexScrollView element"
},
"FlexContainerView":{
"prefix": "contain",
"body": [
"<FlexContainerView name=\"$1\" layout=\"$2\">",
"$3",
"</FlexContainerView>",
],
"description": "FlexContainerView element"
},
"UIImageView":{
"prefix": "image",
"body": [
"<UIImageView attr=\"source:$1\"/>",
],
"description": "UIImageView element"
},
"UITextField":{
"prefix": "text",
"body": [
"<UITextField name=\"$1\" layout=\"$2\" attr=\"fontSize:14,color:black,textAlign:left,placeHolder:$2,text:$3\"/>",
],
"description": "UITextField element"
},
"UITextView":{
"prefix": "text",
"body": [
"<UITextView name=\"$1\" layout=\"$2\" attr=\"fontSize:14,color:black,textAlign:left\"/>",
],
"description": "UITextView element"
},
"UIActivityIndicatorView":{
"prefix": "activity",
"body": [
"<UIActivityIndicatorView layout=\"$1\" attr=\"style:gray,color:darkGray\"/>",
],
"description": "UIActivityIndicatorView element"
},
"UIDatePicker":{
"prefix": "date",
"body": [
"<UIDatePicker layout=\"$1\" attr=\"pickerMode:date\"/>",
],
"description": "UIDatePicker element"
},
"UIProgressView":{
"prefix": "date",
"body": [
"<UIProgressView layout=\"$1\" attr=\"style:bar\"/>",
],
"description": "UIProgressView element"
},
"UISearchBar":{
"prefix": "search",
"body": [
"<UISearchBar layout=\"$1\" attr=\"barStyle:opaque\"/>",
],
"description": "UISearchBar element"
},
"UISlider":{
"prefix": "search",
"body": [
"<UISlider layout=\"$1\" attr=\"minValue:0,maxValue:1,continuous:true,\"/>",
],
"description": "UISlider element"
},
"UISwitch":{
"prefix": "switch",
"body": [
"<UISwitch layout=\"$1\" attr=\"on:false\"/>",
],
"description": "UISwitch element"
},
// uiview attribute
"bgColor":{
"prefix": "bg",
"body": [
"bgColor",
],
"description": "background color"
},
"borderColor":{
"prefix": "bor",
"body": [
"borderColor",
],
"description": "border Color"
},
"borderWidth":{
"prefix": "bor",
"body": [
"borderWidth",
],
"description": "border width"
},
"borderRadius":{
"prefix": "bor",
"body": [
"borderRadius",
],
"description": "border Radius"
},
// flex
"flexDirection":{
"prefix": "flex",
"body": [
"flexDirection",
],
"description": "flexDirection"
},
"justifyContent":{
"prefix": "just",
"body": [
"justifyContent",
],
"description": "justifyContent"
},
"alignItems":{
"prefix": "align",
"body": [
"alignItems",
],
"description": "alignItems"
},
}- 保存,然后再打开xml文件就可以有智能代码片段的提示了
Flexbox Introduction & performance (in Chinese)
Tutorial 1: Create View Controller with xml layout
Tutorial 2: Create Table Cell with xml layout
Tutorial 3: Embed xml layout into traditional view hierarchy
Tutorial 4: Use custom view in xml layout
Tutorial 5: Create reusable view using xml layout file