简体   繁体   中英

Why can't I drag and drop widgets into a toolbar in Android Studio?

I have an Android activity with a Toolbar inside an AppBarLayout and I would like to add widgets to it. When I try to drag and drop a widget onto the Toolbar in the Designer, it doesn't work and the cursor shows a symbol indicating that it can't be added.

There are many questions on StackOverflow all asking the same thing but the answers all seem to be about the distinction between activity_*.xml and content_*.xml . This is not the issue for me, I'm using the activity_*.xml file which definitely includes the Toolbar . I can also add widgets manually in the XML file and they appear in the designer; it's only the drag and drop that isn't working.

Any ideas why this doesn't work or how to make it work?

I'm sorry I still don't have enough reps to comment because this is a new account. But have you tried writing on the xml instead? Right below the palette toolbox, you can switch from design to text and vice versa. And the xml code can easily be googled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM