FrameLayout foreground changes the layout

1.1k views Asked by At

enter image description here

When i add foreground in FrameLayout every child is like padding on the left and top

someone know how to fix this?

layout.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:mwbutton="http://schemas.android.com/apk/res-auto"
    android:id="@+id/FrameLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:foreground="@drawable/view_selector"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:background="#ff0000"
        android:text="TextView" />

</FrameLayout>

selector

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/pretao" android:state_pressed="true"/>
    <item android:drawable="@android:color/transparent"/>

</selector>
1

There are 1 answers

2
Ivo On BEST ANSWER

@drawable/pretao is a 9patch with padding I think.