Skip to main content
# XmlArrangement - Android

* XML Arrangement Rules Generator for Android CodeStyle

---

## Before
```xml
<TextView
android:id="@+id/example"
style="@style/AppTheme.TextView.Example"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:gravity="center_vertical"
tools:text="Lorem Ipsum..."
android:paddingLeft="8dp" />

<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:hint="Hint for Name"
android:layout_height="wrap_content" />

<Button
android:visibility="gone"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentRight="true" />
```

## After
```xml
<TextView
android:id="@+id/example"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:paddingLeft="8dp"
style="@style/AppTheme.TextView.Example"
android:gravity="center_vertical"
tools:text="Lorem Ipsum..."/>

<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint for Name"/>

<Button
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentRight="true"
android:visibility="gone"/>
```

## How to use?

### 1) Create a file to describe your desired order: (empty lines are ignored)

```txt
xmlns:android
xmlns:.*

android:id
android:name

android:layout_width
android:layout_height
android:minWidth
android:minHeight

android:.*
.*
```

See [example.txt](example.txt)

### 2) Run:

```
user@machine:~$ xmlarrangement-android my-order.txt > rules.xml
```

### 3) Install:

* Android Studio **>** Preferences **>** CodeStyle **>** Scheme **>** Manage **>** Export

* Open exported file and rename your scheme, e.g. `<code_scheme name="NewScheme">`

* Find the line `<codeStyleSettings language="XML">`

* You should see a structure like this:
```xml
<arrangement>
<rules>
...
</rules>
</arrangement>
```

* Replace the content inside `<rules></rules>` with the content of `rules.xml`

* Copy new file to Android Studio codestyle path:
* **Mac**: ~/Library/Preferences/AndroidStudioX.X/config/codestyles/
* **Linux**: ~/.AndroidStudioX.X/config/codestyles/
* **Windows**: %USERPROFILE%\\.AndroidStudioX.X\config\codeStyles

* Restart AndroidStudio, go to Preferences **>** CodeStyle **>** Scheme and apply `NewScheme`.


## Installation

- Simple, using PyPI:

```
user@machine:~$ [sudo] pip install xmlarrangement-android
```

- or download the source and:

```
user@machine:~$ [sudo] python setup.py install
```


## References

* [Formatting xml layout files for Android](https://medium.com/@VeraKern/formatting-xml-layout-files-for-android-47aec62722fc#.bt8shn2qx)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xmlarrangement-android-0.1.1.tar.gz (15.6 kB view details)

Uploaded Source

File details

Details for the file xmlarrangement-android-0.1.1.tar.gz.

File metadata

File hashes

Hashes for xmlarrangement-android-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1313bcc4cf37ed923301f4690f600d33e49b1b8821f21924b409402f7efd9b15
MD5 0a896f2aba4295f095295068bc4d53b7
BLAKE2b-256 0ad80926d66a6dde85a79b69ae89d23f987c5e9618cfb589b6e4008be7e8427f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page