question

Kamyarkoushki-8509 avatar image
0 Votes"
Kamyarkoushki-8509 asked RobCaplan edited

Android_app(xamarin)

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


![105841-image.png][3]


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][3]

in this image i put 1 Button and Several chekboxes but all of them are totally and i cant tuning and move there
[1]: /answers/storage/attachments/105800-image.png
[2]: /answers/storage/attachments/105841-image.png
[3]: /answers/storage/attachments/105832-image.png

dotnet-xamarin
image.png (2.1 KiB)
image.png (43.4 KiB)
image.png (119.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT edited

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Kamyarkoushki-8509 avatar image
0 Votes"
Kamyarkoushki-8509 answered

Thankyou very much it was the best help for me
Thankyou

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.