B
B
BYMaz2020-07-15 17:12:42
Android
BYMaz, 2020-07-15 17:12:42

Useless parent layout how to resolve this error?

Faced such a problem, 3 errors appeared in the activiti_main.xml file. What needs to be changed?
Error text:
Error #1 and 2
This LinearLayout l ayout or its RelativeLayout parent is possibly useless A layout with children that has no siblings, is not a scrollview or a root layout, and does not have a background, can be removed and have its children moved directly into the parent for a flatter and more efficient layout hierarchy. Issue id: UselessParent
Error #3
This ScrollView layout or its LinearLayout parent is possibly useless A layout with children that has no siblings, is not a scrollview or a root layout, and does not have a background, can be removed and have its children moved directly into the parent for a flatter and more efficient layout hierarchy. Issue id: UselessParent

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="vertical"
    android:padding="10dp"
    tools:context=".MainActivity">

    <LinearLayout
        android:id="@+id/container1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/container2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="10dp">

            <ScrollView
                android:id="@+id/scroll"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:id="@+id/container3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/textView"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/Marhut2"
                        android:textAlignment="center"
                        android:textColor="#000000"
                        android:textColorHint="#777777"
                        android:textSize="18sp"
                        android:textStyle="bold" />
This is not the whole code, because it did not fit.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2020-07-15
@BYMaz

It's a warning, basically. You need to remove extra layouts, there is no point in nesting them into each other if there are no other children.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question