繁体   English   中英

FrameLayout前景更改布局

[英]FrameLayout foreground changes the layout

在此处输入图片说明

当我在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>

我认为@drawable/pretao是带有填充的9patch。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM