Forum Xamarin.Android

Can't drag a button (or any other thing) to layout of activity_main.axml

YigalBYigalB Member ✭✭

Starting to learn Xamarin, with VS2017.

At first I had errors related to NuGet packages, as it didn't compile out of the box. now I don't see errors displayed.

I am trying to follow a tutorial. First thing was to drag a textview and few buttons to the layout.

The current problem: When I try to drag something from the toolbox (Button, for example) to the layout of activity_main.axml, the system wont let me drop it, showing "no entry" sign.

Any idea what did I miss?

Tagged:

Best Answers

  • YigalBYigalB ✭✭
    Accepted Answer

    For those who will follow my newbies foot steps, here are the 2 steps did to modify the Out Of The Box VS 2017 Android app:
    1- Change RelativeLayout to LinearLayout, in the activityMain.axml. I did it manually because I couldnt locate a flag in the attributes list to do it.
    2- Added android:orientation="vertical" to the activityMain.axml

    Now the text view is not covering the whole screen of the Android phone, and the buttons I drag appear one below the other.

Answers

  • YigalBYigalB Member ✭✭

    @JGoldberger said:
    What tutorial are you trying to follow so I can test making sure I am matching the environment exactly?

    Actually I didn't do a thing from the YouTube tutorial yet. This was the first action, so there is nothing specific yet.

    (Do you have a "hello world" or any tutorial for beginners with Xamarin Android - I will appreciate it.)

    Additionally, I would suggest updating to VS 2019. VS 2017 does not have the latest versions of the Xamarin tooling, and will never get Xamarin updates except for security issues and other very high impact issue fixes.

    I agree, it is my plan, yet I am in a deployment phase of another project for 2-3 months. I prefer not to change versions now, can bring a risk to the system.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Are you on the latest version of Visual Studio 2017? You can find out by opening the Visual Studio Installer app.

    What template did you open when creating the Xamarin.Android project?

    For beginner Xamarin.Android tutorial, try this:
    https://docs.microsoft.com/en-us/xamarin/android/get-started/hello-android/

    Looking at your screen shot again, what happens if you remove the TextureView? It may be that the Texture view is taking up the entire space, and you should not be able to add a button to a TextureView. Did you add the TextureView? I can't think of a template that includes that, but I did add that in my test noted in my last post, and it did not cause any issue.

    Perhaps list the specific steps you took to create the project and get it to the state where adding the button is not being allowed?

  • YigalBYigalB Member ✭✭

    @JGoldberger said:
    Are you on the latest version of Visual Studio 2017? You can find out by opening the Visual Studio Installer app.

    Yes, I have the latest version.

    What template did you open when creating the Xamarin.Android project?

    Blank

    For beginner Xamarin.Android tutorial, try this:
    https://docs.microsoft.com/en-us/xamarin/android/get-started/hello-android/

    Will do, thanks

    Looking at your screen shot again, what happens if you remove the TextureView? It may be that the Texture view is taking up the entire space, and you should not be able to add a button to a TextureView.

    This is it ! I dragged the textview but I didn't notice it covered all the space. So stupid of me!
    I never meant it to cover it all.
    This problem is now solved, thank you so much!
    Now I can continue with learning and Xamarin.

    The good and friendly support is highly appreciated,

  • YigalBYigalB Member ✭✭
    Accepted Answer

    For those who will follow my newbies foot steps, here are the 2 steps did to modify the Out Of The Box VS 2017 Android app:
    1- Change RelativeLayout to LinearLayout, in the activityMain.axml. I did it manually because I couldnt locate a flag in the attributes list to do it.
    2- Added android:orientation="vertical" to the activityMain.axml

    Now the text view is not covering the whole screen of the Android phone, and the buttons I drag appear one below the other.

Sign In or Register to comment.