I'm trying to add some buttons/textviews or any other components to my relativelayout. I can't place them anywhere but top left. However, if I edit XML code it works fine.
Here is the screenshot of current status
I already changed my layout to relativeLayout but still no luck. (Android Studio 3.3)
My layout xml is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/activity_main"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</RelativeLayout>
I would expect to move these buttons/textviews relative to each other but they just stuck at top left.
there is a magnetic button on top of view editor its called (on/off auto connect ). if you change it you can move the views inside relative layout.
relativelayout is deprecated now.
LinearLayout is less used as compared to RelativeLayout. RelativeLayout is used more in applications. We can use LinearLayout inside RelativeLayout. We can also use RelativeLayout as a Child of LinearLayout.
If you have the choice start with ConstraintLayout, but if you already have your app in RelativeLayout, stay with it. That's all I have been following. RelativeLayout is very limited in functionality and many complex layouts can't be made using it, especially when ratios are involved.
there is a magnetic button on top of view editor its called (on/off auto connect ). if you change it you can move the views inside relative layout.
Just Enable AutoConnection to Parent
In Design Mode click the magnet icon and choose "AutoConnection to Parent"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With