FrameLayout前景改变了布局

时间:2013-12-16 14:45:40

标签: android selector android-framelayout foreground

enter image description here

当我在FrameLayout中添加前景时,每个孩子都像左边和上面的填充

有人知道如何解决这个问题吗?

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>

选择器

<?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 个答案:

答案 0 :(得分:1)

我认为

@drawable/pretao是一个带有填充的9patch。