0

I'm trying to design a GUI using the Android GUI builder in Eclipse. I want to use the android.support.design.widget.TextInputLayout, but I don't see it in the palette view.

  • I have already imported the appcompat_v7 library into the workspace as a project and referenced to it from my Android project;
  • I have already imported the design support library into the workspace as a project and referenced to it from my Android project;
  • I've set the build path to Android API level 23 (the newest at the moment) to prevent errors like No resource found... from being issued;
  • I've cleaned all my projects;
  • I've restarted Eclipse.

How can I make sure the TextInputLayout is available in the palette view?

Community
  • 1
  • 1
MC Emperor
  • 22,334
  • 15
  • 80
  • 130
  • Last I knew, Eclipse didn't support any widgets from libraries, whether those are official support libraries or not. Of course, I haven't touched Eclipse in quite some time. – CommonsWare Feb 04 '16 at 19:48
  • You can't, I would stay away from the Eclipse GUI builder it'll give you more issues than it's worth. Why don't you just use `XML` view? – Pztar Feb 04 '16 at 19:50
  • Okay... And what about Android Studio? – MC Emperor Feb 04 '16 at 20:55

1 Answers1

0

I haven't found a way to get library widgets to work (though widgets from the project itself do show up – though they don't always work, seems to depend on the widget).

However, there is a workaround: if you add them to the XML file, you can view and edit them in the visual editor. You can add the widget entirely by hand, or find its "native" ancestor: According to the docs, android.support.design.widget.TextInputLayout extends LinearLayout, therefore simply drop a LinearLayout into your layout, then go to the XML and change

<LinearLayout ... />

to

<android.support.design.widget.TextInputLayout ... />

Eclipse may add a xmlns:app attribute to your top layout (and then complain about it being invalid). Simply change its contents to

xmlns:app="http://schemas.android.com/apk/res-auto"

Whenever you edit attributes, Eclipse will add another xmlns:app1 attribute – simply delete it and change your widget's app1:* attributes to app:*.

The whole thing is a bit buggy and requires manual intervention, but works eventually.

user149408
  • 5,385
  • 4
  • 33
  • 69