Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7880739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:12:58+00:00 2026-06-03T04:12:58+00:00

I have some layout file which Lint is giving me the following warning about:

  • 0

I have some layout file which Lint is giving me the following warning about:

UselessParent

Summary: Checks whether a parent layout can be removed.

Priority: 2 / 10 Severity: Warning Category: Performance

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.

The part I’m confused about is in bold. My layout (before fixing this warning) is as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/default_margin"
        android:paddingTop="@dimen/default_margin_small"
        android:paddingBottom="@dimen/default_margin_small">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingRight="@dimen/default_margin"
            android:orientation="vertical">

            <!-- TEXTVIEWS & EDITTEXTS HERE -->

        </LinearLayout>

    </ScrollView>

</LinearLayout>

But I fixed the warning like this:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/default_margin"
    android:paddingTop="@dimen/default_margin_small"
    android:paddingBottom="@dimen/default_margin_small">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingRight="@dimen/default_margin"
        android:orientation="vertical">

        <!-- TEXTVIEWS & EDITTEXTS HERE -->

    </LinearLayout>

</ScrollView>

This makes sense to me but the bold part above in the Lint check is confusing me a bit, because I do have a ScrollView inside a LinearLayout. Should I not be fixing it like this or is there no problem having a ScrollView as root element for a layout file since a ScrollView inherits from FrameLayout anyway?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:13:00+00:00Added an answer on June 3, 2026 at 4:13 am

    There is no problem having a ScrollView as root element for a layout file. The lint complaint presumably was about your original root LinearLayout, which was not adding any value with just the ScrollView as a child.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which contains text with some very simple layout constructs:
I have a simple layout file which displays the icons and some text view
I have layout file which I'm inflating dynamically on the screen. Then in my
Is it possible to convert R.java into layout file xxx.xml.. In some project which
I am new to NDK. I have a cpp file which has the following
I have some text views in an linear layout in my android application. Next
I face some layout differences in IE and in Chrome. I have searched Stack
I'm working on a fluid layout project. I have some fixed height DIVs in
We have an adaptive layout where some list elements are displayed horizontally: | Li1
I have problems getting some of my views aligned in a relative layout that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.