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

时间:2016-07-11 23:01:35

标签: android android-studio android-toolbar android-appbarlayout

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?

1 个答案:

答案 0 :(得分:0)

对不起,我还没有足够的代表发表评论,因为这是一个新帐户。但是你尝试过在xml上写作吗?在调色板工具箱的正下方,您可以从设计切换到文本,反之亦然。 xml代码可以很容易地用Google搜索。