Android_app(xamarin)

Kamyar koushki 41 Reputation points
2021-06-15T12:12:38.98+00:00

Hello
my problem is in "activity_main.xml"
![105756-image.png]2

105841-image.png

In the toolbox, when I put buttons on the Visual Studio mobile emulator, they overlap and can not be adjusted and placed
105832-image.png

in this image i put 1 Button and Several chekboxes but all of them are totally and i cant tuning and move there

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,336 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 74,641 Reputation points Microsoft Vendor
    2021-06-16T03:22:07.017+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Please open the activity_main.xml code. Change the RelativeLayout to LinearLayout and add android:orientation="vertical" to LinearLayout like following code.

       <?xml version="1.0" encoding="utf-8"?>  
       <LinearLayout  
           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:orientation="vertical"  
           android:layout_width="match_parent"  
           android:layout_height="match_parent">  
           <Button  
               android:text="Button1"  
               android:layout_width="match_parent"  
               android:layout_height="wrap_content"  
               android:id="@+id/button2" />  
         
           <Button  
               android:text="Button2"  
               android:layout_width="match_parent"  
               android:layout_height="wrap_content"  
               android:id="@+id/button1" />  
         
          
       </LinearLayout >  
    

    Then all the controls will be moved, will not overlap;

    Here is similar thread about this issue. And Jon explain the details about why controls cannot be moved in RelativeLayout

    https://forums.xamarin.com/discussion/180225/cant-drag-a-button-or-any-other-thing-to-layout-of-activity-main-axml

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Kamyar koushki 41 Reputation points
    2021-06-16T14:56:00.157+00:00

    Thankyou very much it was the best help for me
    Thankyou

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.