[英]Get the Xamarin Android Designer to work with the Toolbox
This question is about Xamarin Android which supports drag and drop functionality, not Xamarin Forms. 这个问题是关于支持拖放功能的Xamarin Android,而不是Xamarin Forms。
When using the Xamarin Android Designer in Visual Studio I am only allowed to drag in one control from the toolbox. 在Visual Studio中使用Xamarin Android Designer时,我只能从工具箱中拖入一个控件。 After this, I am no longer able to add any new buttons (with the cursor changing to a "not allowed" symbol when trying to drag in a new button). 在此之后,我无法再添加任何新按钮(当尝试拖动新按钮时光标变为“不允许”符号)。
Steps to reproduce the problem: 重现问题的步骤:
I've looked online for a solution, including Xamarin Community Forums and the Visual Studio Developer Community and but have only found posts on the same or similar issue with no solution that has worked for me. 我已经在网上找到了一个解决方案,包括Xamarin社区论坛和Visual Studio开发者社区,但只发现了相同或类似问题的帖子,没有对我有用的解决方案。 How can I solve this? 我怎么解决这个问题?
RelativeLayout
in Xaml doesn't allow drag&droping more than 1 control by design. Xaml中的RelativeLayout
不允许按设计拖放多于1个控件。
RelativeLayout
is a ViewGroup
that displays child View elements in relative positions. RelativeLayout
是一个ViewGroup
,它以相对位置显示子View元素。 The position of a View can be specified as relative to sibling elements (such as to the left-of or below a given element) or in positions relative to the RelativeLayout
area (such as aligned to the bottom, left of center). 视图的位置可以指定为相对于同级元素(例如,给定元素的左侧或下方)或相对于RelativeLayout
区域的位置(例如与中心的底部,左侧对齐)。
Basically, designer let you add only one control on which you design your interface. 基本上,设计师允许您只添加一个控件来设计界面。 You position the other controls from Xaml based on original dragged control. 您可以根据原始拖动控件从Xaml定位其他控件。 You can drag&drop controls from toolbox directly to Xml code and it allows you to edit further the control from Properties box. 您可以将控件从工具箱直接拖放到Xml代码,它允许您从“属性”框中进一步编辑控件。
Also, https://developer.android.com/guide/topics/ui/layout/relative officially recommends to use ConstraintLayout
instead. 此外, https://developer.android.com/guide/topics/ui/layout/relative正式建议使用ConstraintLayout
。
If you insists to use RelativeLayout
, you will have to code the interface in Xaml. 如果您坚持使用RelativeLayout
,则必须在Xaml中对接口进行编码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.