From 52724245e110cfea9d94ea8dc3edaae0d170542b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Kowalski?= Date: Mon, 5 Aug 2019 17:34:39 +0200 Subject: [PATCH 1/2] Add section on XML layouts #38 --- kotlin.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/kotlin.md b/kotlin.md index 8a17ab2..b45821f 100644 --- a/kotlin.md +++ b/kotlin.md @@ -235,3 +235,61 @@ Examples of specific strings: 24dp 32dp ``` + +### 6. Layouts + +* Always to keep 4 spaces of indentation between levels. +* Prevent double indentation between element name and first property +(which is a default behaviour of android studio) +* Place `android:id` at the first position. +* Place `style` after `android:id`. +* Place `android:layout_width` and `android:layout_height` after `style`. +* Try to keep similar order of properties in different layout's element. +* Always use resources for values such as dimens, strings or colors. + + +Example of well formatted xml: +```xml + + + + + + + + + + + + + + +``` From ca8e144600302155abc27dce40b9fc996fb65d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Kowalski?= Date: Mon, 5 Aug 2019 17:44:20 +0200 Subject: [PATCH 2/2] Add tip about auto-sorting in android studio #59 --- kotlin.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kotlin.md b/kotlin.md index b45821f..08354ff 100644 --- a/kotlin.md +++ b/kotlin.md @@ -293,3 +293,8 @@ Example of well formatted xml: ``` + +Android Studio provides a feature that allows you automatically sort and +reformat layout. Just use a shortcut `Shift + Ctrl + l`. It works quite well +and can be helpful during development process, but you have to pay +attention to be sure, it respects rules above.