-
Notifications
You must be signed in to change notification settings - Fork 7
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
Request: offer to merge margins/padding when possible, into horizontal/vertical/all #16
Comments
Note that in styles file, sadly |
Yep, nice idea! |
As I remember, this is possible on old versions of Android thanks to android-x. |
Not really, this is AAPT's job: https://android.googlesource.com/platform/frameworks/base/+/master/tools/aapt2/readme.md#version-2_16 The safest way is to go with minSdk 26 but who will use it?.. |
OK so I forgot how it worked. Sorry. You can also have an inspection for weird cases, such as |
Agree. |
What do you mean? |
The question is how to warn. For example, I could grey out an attribute and say “paddingLeft is overridden by padding” |
I would prefer to be strict about it, not allowing such mixes, and the warning would say about it in general. Of course, you can make this inspection optional |
Done! |
What's done? Everything? Padding, margins...? |
Reporting on attributes which could or will be overridden by others. |
I don't understand. Are you talking now about the mixed, weird cases? |
Oh, I've forgot about merging 😟 |
Merging was the original idea. The mixed cases are a special case of it... |
Was it now added? |
Thank you! |
@Miha-x64 For some reason I can't find this inspection (v0.24). How is it called? Here's what I see when I search "Mike": |
@AndroidDeveloperLB |
@Miha-x64 It doesn't talk about padding/margins: "Reports useless elements of XML Drawable resources, such as single-item layer-lists, insetless insets, empty shapes, and vector elements: empty paths and clip-paths, invisible paths, useless clip-paths and groups, attributes with no effect." And, after analyzing, I don't see even one example that it offers to merge, even though there should be... Are you sure that's correct? |
@AndroidDeveloperLB, I will extend inspection description to mention all its features.
Please submit a separate issue with a reproducer. |
Meaning in layout XML file, if there is
android:layout_marginLeft="20dp" android:layout_marginRight="20dp"
, offerandroid:layout_marginHorizontal="20dp"
.Same goes for
android:layout_marginStart="20dp" android:layout_marginEnd="20dp"
to offerandroid:layout_marginHorizontal="20dp"
.And of course for vertical ones, from
android:layout_marginTop="20dp" android:layout_marginBottom="20dp"
intoandroid:layout_marginVertical="20dp"
.And the very rare case of all sides that are the same, from
android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="20dp" android:layout_marginBottom="20dp"
into justandroid:layout_margin="20dp"
. And the same if used with start&end.Of course, if there is a mix that contradicts the merging, don't offer it. For example
android:layout_marginLeft="20dp" android:layout_marginStart="15dp"
. However, if there is a mix that is identical (start&end&left&right with the same value, for example), offer to merge.Same goes for padding.
If the mix is weird, I suggest to warn about it, as a different inspection.
The text was updated successfully, but these errors were encountered: