Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
[ID: 558956]
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Problem: UselessParent issue is not reported for children that declare paddingLeft/passingRight elements.
Steps to reproduce:
1. Given the following layout xml, the inner child namely RelativeLayout uses paddingLeft/paddingRight elements.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
</FrameLayout>
2. Parent of RelativeLayout does not have a background attribute declaration
Expected:
Lint should report "The RelativeLayout layout or it's FrameLayout parent is useless"
Observed:
No lint warning.
Aside: Fix is in sight. (Simple 2 char fix)
This happens because the UselessViewDetector.checkUselessMiddleLayout(..) returns early if any of the paddingLeft/paddingRight/paddingBottom/paddingTop are defined on the layout being checked. The fix is to simply ensure that this is done *only* if the parent declares a background.