Android 带有EditText的ViewSwitcher保留了额外的填充

Android 带有EditText的ViewSwitcher保留了额外的填充,android,android-layout,android-edittext,android-ui,viewswitcher,Android,Android Layout,Android Edittext,Android Ui,Viewswitcher,我使用ViewSwitcher允许从TextView切换到EditText元素。我注意到EditText元素会在视图底部生成额外的填充(即,如果我删除EditText,所有内容看起来都与预期的一样,但是添加它,即使可见性设置为“消失”,也会在底部生成额外的空间)。这是什么原因造成的,应该如何解决 <ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/Ingredie

我使用ViewSwitcher允许从TextView切换到EditText元素。我注意到EditText元素会在视图底部生成额外的填充(即,如果我删除EditText,所有内容看起来都与预期的一样,但是添加它,即使可见性设置为“消失”,也会在底部生成额外的空间)。这是什么原因造成的,应该如何解决

<ViewSwitcher
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/IngredientsLineSwitcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
    <TextView 
        android:id="@+id/IngredientsLineText"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:paddingBottom="0dip"
        android:paddingLeft="10dip"
        android:paddingTop="0dip"
        android:text=""
        android:textColor="@color/black"
        android:textSize="@dimen/recipe_label_font_size" />
    <EditText
        android:id="@+id/IngredientsLineEdit"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"      
        android:paddingBottom="0dip"
        android:paddingLeft="10dip"
        android:paddingTop="0dip"
        android:text=""
        android:visibility="gone"
        android:textColor="@color/black"
        android:textSize="@dimen/recipe_label_font_size" /> 
</ViewSwitcher>

您应该在
文本视图
编辑文本
周围放置一个
RelativeLayout
,以控制它们的位置。

-----
-----
android:layout_height="match_parent" >
mlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/IngredientsLineSwitcher"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView 
    android:id="@+id/IngredientsLineText"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
  ----
<EditText
    android:id="@+id/IngredientsLineEdit"
    android:layout_height="match_parent"
    android:layout_width="match_parent"      
   -----
android:layout\u height=“match\u parent”> mlns:android=”http://schemas.android.com/apk/res/android" android:id=“@+id/IngredientsLineSwitcher” android:layout\u width=“匹配父项” android:layout\u height=“match\u parent”>