Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ktlint affects android xml format #322

Closed
AllanWang opened this issue Dec 24, 2018 · 2 comments
Closed

Ktlint affects android xml format #322

AllanWang opened this issue Dec 24, 2018 · 2 comments

Comments

@AllanWang
Copy link

It's weird that no one else seems to have this issue, but after running ktlint --apply-to-idea-project --android, my xml format seems to be messed up.

Before:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/image_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ProgressBar
        android:id="@+id/image_progress"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        android:id="@+id/image_panel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        app:umanoPanelHeight="44dp"
        app:umanoShadowHeight="0dp">

        <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
            android:id="@+id/image_photo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:alpha="0"
            android:scaleX="0.9"
            android:scaleY="0.9" />

        <TextView
            android:id="@+id/image_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:alpha="0.5"
            android:padding="@dimen/kau_padding_normal" />

    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/image_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/kau_fab_margin"
        android:visibility="invisible" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

After:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                                     xmlns:app="http://schemas.android.com/apk/res-auto"
                                                     android:id="@+id/image_container"
                                                     android:layout_width="match_parent"
                                                     android:layout_height="match_parent">

    <ProgressBar
            android:id="@+id/image_progress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"/>

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
            android:id="@+id/image_panel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="bottom"
            app:umanoPanelHeight="44dp"
            app:umanoShadowHeight="0dp">

        <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
                android:id="@+id/image_photo"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:alpha="0"
                android:scaleX="0.9"
                android:scaleY="0.9"/>

        <TextView
                android:id="@+id/image_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:alpha="0.5"
                android:padding="@dimen/kau_padding_normal"/>

    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/image_fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:layout_margin="@dimen/kau_fab_margin"
            android:visibility="invisible"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

The problem is that the continuation indent went from 4 to 8, and align attributes is true.

Is this expected? These don't seem to follow the android layout pattern. Example from AOSP

@shyiko shyiko closed this as completed in 2ab0a6d Feb 12, 2019
@AllanWang
Copy link
Author

Hey @shyiko,

looking at your commit, are you opting to make the second format default or the first? Default in Android Studio and in most code seems to specify 4 spaces as continuation

@shyiko
Copy link
Collaborator

shyiko commented Feb 13, 2019

@AllanWang first (4 spaces for continuation indentation)
(name="CONTINUATION_INDENT_SIZE" value="8" is replaced with continuation_indent_size (which is 4 by default))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants