user-1
user-1

Reputation: 1

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.

When using the Xamarin Android Designer in Visual Studio I am only allowed to drag in one control from the toolbox. 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:

  1. Create a new Xamarin Android App project in Visual Studio.
  2. Navigate to the "Resources/layout/activity_main.axml".
  3. Try to add two buttons to the Design. Trying to add the second one will show the "not allowed" symbol in place of the cursor.

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. How can I solve this?

Upvotes: 0

Views: 625

Answers (1)

user10627299
user10627299

Reputation: 9234

RelativeLayout in Xaml doesn't allow drag&droping more than 1 control by design.

RelativeLayout is a ViewGroup that displays child View elements in relative positions. 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).

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. You can drag&drop controls from toolbox directly to Xml code and it allows you to edit further the control from Properties box.

Also, https://developer.android.com/guide/topics/ui/layout/relative officially recommends to use ConstraintLayout instead.

If you insists to use RelativeLayout, you will have to code the interface in Xaml.

Upvotes: 1

Related Questions