Sketchware 레이아웃 디자이너 기술
개요
이 기술은 Sketchware Pro 프로젝트의 UI 계층을 생성하고 관리하는 데 특화되어 있습니다. .swb 백업 패키지의 data/view에 필요한 정확한 JSON 사양을 생성하며, 위젯 계층 구조, 스타일링, 반응형 레이아웃 및 플로팅 액션 버튼(FAB)을 완벽하게 지원합니다.
1. 백업 아카이브의 파일 구조
Sketchware 프로젝트 또는 .swb 아카이브에서 모든 화면 레이아웃은 단일 AES 암호화 파일 data/view에 결합됩니다.
다중 화면 및 섹션 헤더
레이아웃은 섹션 마커로 구분됩니다.
@<activity_xml_name>.xml(예:@main.xml,@home.xml)@<activity_xml_name>.xml_fab(플로팅 액션 버튼이 있는 활동의 경우)@<custom_view_name>.xml(ListView/Spinner에 사용되는 CustomView의 경우)
@main.xml
<보기 1에 대한 ViewBean JSON>
<보기 2에 대한 ViewBean JSON>
<보기 3에 대한 ViewBean JSON>
@main.xml_fab
<FAB에 대한 ViewBean JSON>
@item_row.xml
<사용자 지정 보기 항목에 대한 ViewBean JSON>
2. ViewBean JSON 스키마 및 필수 필드
모든 UI 요소는 ViewBean을 나타내는 한 줄 JSON 문자열입니다.
{
"id": "button_submit",
"type": 3,
"parent": "root",
"parentType": 0,
"index": 0,
"convert": "Button",
"customView": "",
"enabled": 1,
"clickable": 1,
"alpha": 1.0,
"translationX": 0.0,
"translationY": 0.0,
"scaleX": 1.0,
"scaleY": 1.0,
"firstDayOfWeek": 1,
"dividerHeight": 1,
"choiceMode": 0,
"checked": 0,
"indeterminate": "false",
"progress": 0,
"max": 100,
"progressStyle": "?android:progressBarStyle",
"spinnerMode": 1,
"inject": "",
"adSize": "",
"adUnitId": "",
"preIndex": 0,
"preParentType": -1,
"parentAttributes": {},
"layout": {
"width": -1,
"height": -2,
"orientation": -1,
"gravity": 0,
"layoutGravity": 0,
"weight": 0,
"weightSum": 0,
"marginLeft": 16,
"marginTop": 16,
"marginRight": 16,
"marginBottom": 16,
"paddingLeft": 12,
"paddingTop": 12,
"paddingRight": 12,
"paddingBottom": 12,
"backgroundColor": 16777215,
"borderColor": -16740915
},
"text": {
"text": "Submit",
"textSize": 16,
"textColor": -16777216,
"hint": "",
"hintColor": 16777215,
"singleLine": 0,
"line": 0,
"inputType": 1,
"imeOption": 0,
"textFont": "default_font",
"textType": 1
},
"image": {
"rotate": 0,
"scaleType": "CENTER"
}
}
3. 위젯 및 레이아웃 유형 상수
| 유형 정수 | 위젯 / 레이아웃 클래스 | convert 문자열 | 설명 |
|---|---|---|---|
0 | LinearLayout | LinearLayout | 선형 컨테이너 (가로 또는 세로) |
1 | RelativeLayout | RelativeLayout | 상대적 컨테이너 |
2 | HorizontalScrollView | HorizontalScrollView | 가로 스크롤 컨테이너 |
3 | Button | Button | 대화형 푸시 버튼 |
4 | TextView | TextView | 텍스트 표시 레이블 |
5 | EditText | EditText | 텍스트 입력 필드 |
6 | ImageView | ImageView | 이미지 컨테이너 |
7 | WebView | WebView | 앱 내 브라우저 / 웹 프레임 |
8 | ProgressBar | ProgressBar | 원형 또는 수평 로딩 표시기 |
9 | ListView | ListView | 스크롤 가능한 세로 항목 목록 |
10 | Spinner | Spinner | 드롭다운 선택 목록 |
11 | CheckBox | CheckBox | 두 가지 상태 확인 가능한 상자 |
12 | ScrollView | ScrollView | 세로 스크롤 컨테이너 |
13 | Switch | Switch | 두 가지 상태 토글 스위치 |
14 | SeekBar | SeekBar | 드래그 가능한 값 슬라이더 |
15 | CalendarView | CalendarView | 대화형 월 달력 |
16 | FloatingActionButton | FloatingActionButton | 표준 Material FAB (_fab 섹션) |
17 | AdView | AdView | Google AdMob 배너 |
18 | MapView | MapView | Google Maps 컨테이너 |
4. 계층 구조 및 상위 규칙 (중요)
- 루트 수준 뷰:
- 화면 베이스에 직접 연결된 요소의 경우
"parent": "root"로 설정합니다. "parentType": 0(FAB의 경우-1)로 설정합니다.
- 화면 베이스에 직접 연결된 요소의 경우
- 컨테이너의 하위 뷰:
"parent": "<container_view_id>"로 설정합니다 (예:"parent": "linear_main")."parentType": <container_type_int>로 설정합니다 (예: LinearLayout의 경우0).
- 인덱스 순서:
"index"는 동일한"parent"를 공유하는 형제 간에0, 1, 2, 3...순차적으로 지정되어야 합니다.
- 레이아웃 크기:
MATCH_PARENT:-1WRAP_CONTENT:-2- 정확한 DP: 양의 정수 (예: 48dp의 경우
48).
- 선형 레이아웃 방향:
- 가로:
"orientation": 0 - 세로:
"orientation": 1 - 비컨테이너 위젯:
"orientation": -1
- 가로:
5. 스타일링, 색상 및 타이포그래피
- ARGB 16진수를 32비트 부호 있는 정수로 변환:
Sketchware는 색상을 32비트 부호 있는 정수로 저장합니다.
- 투명 / 기본값:
16777215(0x00FFFFFF) - 검은색 (
#FF000000):-16777216 - 흰색 (
#FFFFFFFF):-1 - Sketchware 기본 파란색 (
#FF008DCD):-16740915 - Material 강조 빨간색 (
#FFFF4081):-49023 - Material 회색 (
#FF9E9E9E):-6381922
- 투명 / 기본값:
- 텍스트 스타일 (
textType):0: 일반1: 굵게2: 기울임꼴3: 굵은 기울임꼴
- 입력 유형 (
EditText의inputType):1: 일반 텍스트2: 텍스트 (제안 없음)33: 이메일 주소 (TYPE_TEXT_VARIATION_EMAIL_ADDRESS)129: 비밀번호 (TYPE_TEXT_VARIATION_PASSWORD)2: 숫자 (TYPE_CLASS_NUMBER)3: 전화번호 (TYPE_CLASS_PHONE)
- 스케일 유형 (
ImageView의scaleType):"CENTER","CENTER_CROP","CENTER_INSIDE","FIT_CENTER","FIT_START","FIT_END","FIT_XY"
6. 플로팅 액션 버튼 (FAB) 설정
활동에서 FAB를 활성화하는 경우:
data/file(@activity)에서"options": 1(또는 FAB가 있는 비트마스크)로 설정합니다.data/view에서@<activity>.xml_fab아래에 항목을 추가합니다.
@main.xml_fab
{"adSize":"","adUnitId":"","alpha":1.0,"checked":0,"choiceMode":0,"clickable":1,"convert":"","customView":"","dividerHeight":1,"enabled":1,"firstDayOfWeek":1,"id":"_fab","image":{"rotate":0,"scaleType":"CENTER"},"indeterminate":"false","index":0,"inject":"","layout":{"backgroundColor":16777215,"borderColor":-16740915,"gravity":0,"height":-2,"layoutGravity":85,"marginBottom":16,"marginLeft":16,"marginRight":16,"marginTop":16,"orientation":-1,"paddingBottom":0,"paddingLeft":0,"paddingRight":0,"paddingTop":0,"weight":0,"weightSum":0,"width":-2},"max":100,"parentAttributes":{},"parentType":-1,"preIndex":0,"preParentType":0,"progress":0,"progressStyle":"?android:progressBarStyle","scaleX":1.0,"scaleY":1.0,"spinnerMode":1,"text":{"hint":"","hintColor":16777215,"imeOption":0,"inputType":1,"line":0,"singleLine":0,"text":"","textColor":16777215,"textFont":"default_font","textSize":12,"textType":0},"translationX":0.0,"translationY":0.0,"type":16}
data/logic에서 클릭 이벤트는_fab대상에 바인딩됩니다.- 이벤트 헤더:
@MainActivity.java_events->{"eventName":"onClick","eventType":1,"targetId":"_fab","targetType":16} - 로직 블록 헤더:
@MainActivity.java__fab_onClick
- 이벤트 헤더:
7. 기술 간 통합 프로토콜
sketchware-events-manager와 함께: 여기서 생성된 모든 대화형 뷰(Button,EditText,ImageView,ListView,_fab)는data/logic에서 해당id및targetType을 통해 클릭, 변경 및 항목 리스너에 참조됩니다.sketchware-blocks-engine과 함께: 뷰 ID는 UI 블록 매개변수(예:setText,getText,setVisible,setImageUrl)에 전달됩니다.sketchware-project-generator와 함께: 생성된 뷰 JSON 문자열은 해당@<screen>.xml헤더 아래에 결합되어data/view로 암호화됩니다.