How to use Constraints Layout?

Hi,

Did anyone know how to apply the constraints layout?
Like in android studio, they have a feature where user can drag and resize according to the position they wanted by using constraints layout.

I was wandering did Visual Studio to have such function?

Please kindly advice me.
Thanks :smile:

Best Answers

  • CaptainSamuelCaptainSamuel MYMember ✭✭
    Accepted Answer

    Hi @AlbertK

    Thanks for the guidance, I'll tried to uninstall and install again.
    Will update you :wink:

Answers

  • PhilippeTPhilippeT FRMember ✭✭
    edited June 14

    But i don't find any information about VS support.

    Here is the nuget : https://github.com/xamarin/AndroidSupportComponents/tree/master/constraint-layout
    You may use the Android Layout Editor to skin your layouts/drawables/... then copy/paste on Visual Studio Resource folder. You will have a lot of other interesting functionalities for the Resource Management :wink:

    PS : When you are good, If want see them in the VS designer. Just rename xml extensions in your layout folders to axml (or reciprocally) .

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @PhilippeT

    I already downloaded but how to install the nuget?

  • PhilippeTPhilippeT FRMember ✭✭
    edited June 15

    how to install the nuget?

    Standard way. Maybe, you don't find it cause it still in beta ? ( select 'beta' option in the package Manager )

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @PhilippeT

    Is this is the right way to add the nuget?

    What is the source I need to point to?

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    @AlbertK said:
    Go to VS Menu -> Tools -> Nuget Package Manager -> Manage Nuget Package for Solutions

    Hi @AlbertK

    I cannot find "Manage Nuget Package for Solutions"

  • AlbertKAlbertK MYMember ✭✭✭

    Which version of Visual Studio (VS) do you have?

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @AlbertK

    I am using Visual Studio Community 2015 with updates

  • AlbertKAlbertK MYMember ✭✭✭

    I have the same VS 2015 and I have that option. If you still have problem, maybe it is time to uninstall and reinstall VS 2015.

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @AlbertK

    Is this work for Community Version as well?

  • AlbertKAlbertK MYMember ✭✭✭

    Yes, I am on Visual Studio 2015 Community Edition. If you do not have that menu option then something is wrong with you install. You can send more time trying to troubleshoot it or bite the bullet and uninstall and install the VS 2015.

    I have spend weeks on end to fix missing Android SDK and in the end, I end up doing the uninstall and install back. I know it is painful but most likely the quickest way to the the whole thing working. Hope this helps.

  • CaptainSamuelCaptainSamuel MYMember ✭✭
    Accepted Answer

    Hi @AlbertK

    Thanks for the guidance, I'll tried to uninstall and install again.
    Will update you :wink:

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @AlbertK

    I have reinstall the VS 2015 Community Edition, and I found that it wasn't the version issue. It is because I did now open any project thus the "Manage NuGet Packages for Solution" is not shown.

    Anyway, it is fixed after I open a project and I could see the "Manage NuGet Packages for Solution".
    But a very strange as I try to add the NuGet for the Constraint Layout, I get the following error

    "Error Could not install package 'Xamarin.Android.Support.Constraint.Layout.Solver 1.0.0-beta5'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."

    Any Idea how to fix the issue?

  • AlbertKAlbertK MYMember ✭✭✭

    Go to VS 2015 Menu -> Project -> Appname Properties -> Application -> Compile using Android Version (Target Framework)

    What does it say ?

    Go to VS 2015 Menu -> Help -> About (Scroll to the bottom)

    What is the version of Xamarin, Xamarin.Android ?

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @AlbertK

    Target Framework is "Use Compile using SDK Version"
    Xamarin 4.2.1.62 (680125b)
    Xamarin.Android 7.0.2.37 (ce955cc)

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @AlbertK

    I have selected Android 7.0

    But still same issue

  • AlbertKAlbertK MYMember ✭✭✭

    The first drop down , what is you are changing is the third drop down, Change back the third drop down option to the default.

    Looking at you screenshot it looks like the highest version is Android 6.0. Please upgrade as per my instruction.

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @AlbertK

    I have upgraded the Xamarin and it works.
    Just want to know how can I re-positioned the items like I did in the AndroidStudio?

    Because when I tried to copy the Source code from AndroidStudio to VS it gives me a lot of warnings.

  • CaptainSamuelCaptainSamuel MYMember ✭✭

    Hi @AlbertK

    I need help on the constraints as in source code I coded

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    </android.support.constraint.ConstraintLayout>

    But in the Designer it doesn't appear as what I design.

    Any idea why it doesn't show up?

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    The graphical design viewer for Xamarin.Android is like red headed step child in the Xamarin family. Even up to today the viewer will hang once in a while and also extremely slow (that is using stock standard component/widget).

    I could not offer any help here.

  • CaptainSamuelCaptainSamuel MYMember ✭✭
    Hi @AlbertK

    Is okay. It seems like Constraint is not working. But I used the Relative Layout and result is amazing
  • Hi @CaptainSamuel I hope this could help you.
    I used android studio for designing then copy-paste the result xml src to Visual Studio Designer.

Sign In or Register to comment.