0

I am studying android. To check how something works I want to comment out parts of layout. I am aware of XML style <!-- --> comment but I want to be able to comment out individual attributes like android:theme here:

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        // android:theme="@style/Theme.ScrollStub2.AppBarOverlay"
        android:layout_width="match_parent"

except // doesn't work in XML.

Is there the way?

EDIT: To clarify, I need just any way to make android studio ignore the attribute, without having to delete it. I didn't want to comment out 'block' or 'arbitrary line' as in other suggested questions. I tried changing name to non-existent attribute e.g. theme -> xtheme, but studio refuses to build such project.

Uprooted
  • 941
  • 8
  • 21
  • @a_local_nobody not exactly, it's about attribute block, I just need to comment single attribute. I would be happy with just mangling attribute name, e.g. theme -> xtheme, but then studio complains about unknown attribute. Still I believe it's possible, unlike commenting out a whole block. – Uprooted Jan 04 '22 at 12:43
  • Did you try the `#` character to "comment it out"? Or `/* ... */`? Seriously, this is a super easy question regarding **very basic** XML syntax, that has nothing to do with Android or "android layout". – terrorrussia-keeps-killing Jan 04 '22 at 12:46
  • @fluffy first, stackoverflow is mostly useful for basic questions imo. Second, I just tried /* */ and # and both don't work obviously, why you even suggested it, it's not bash or C, it's xml. – Uprooted Jan 04 '22 at 12:48
  • Of course it is not. Obviously it is not. I'm wondering **why** you decided that `//` must work not even trying to read about the syntax basics that are very, very, and very easy to find without raising a new noisy question that takes time of others (even for those who close such questions like duplicates). Think of it. – terrorrussia-keeps-killing Jan 04 '22 at 12:52
  • @fluffy I used // as an illustration of what I am trying to do. I never meant it should work. – Uprooted Jan 04 '22 at 12:55
  • 1
    @fluffy btw just found an answer, created additional fake namespaces _app and _android so now I can do ```android:theme=``` -> ```_android:theme=```, _ works just like a comment. Spent more typing on SO than on actual answer. – Uprooted Jan 04 '22 at 13:10

1 Answers1

1

You can't comment attributes of an XML Tag. You have to comment the full XML Tag.

Umut Can
  • 41
  • 2