Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 更改方向时,“编辑文字高度”会增加_Android_Size_Android Edittext_Orientation Changes - Fatal编程技术网

Android 更改方向时,“编辑文字高度”会增加

Android 更改方向时,“编辑文字高度”会增加,android,size,android-edittext,orientation-changes,Android,Size,Android Edittext,Orientation Changes,在我的应用程序中,我将屏幕方向锁定为纵向。但当用户点击编辑文本框时,我会改变这一点。在纵向模式下,它工作正常。但在横向模式下,编辑文本高度几乎是实际大小的两倍。下面是我编辑文本的xml <EditText android:id="@+id/mylist_AddNewFFtext" android:layout_width="fill_parent" android:layout_height="0dp" android:lay

在我的应用程序中,我将屏幕方向锁定为纵向。但当用户点击编辑文本框时,我会改变这一点。在纵向模式下,它工作正常。但在横向模式下,编辑文本高度几乎是实际大小的两倍。下面是我编辑文本的xml

<EditText
        android:id="@+id/mylist_AddNewFFtext"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@drawable/mylist_stdcenterelement"
        android:imeOptions="actionSend|actionGo|actionDone"
        android:inputType="text|textCapWords"
        android:maxLength="1000"
        android:padding="5dp"
        android:textColor="@android:color/black"
        android:textSize="14sp"
        android:textStyle="bold"
        android:visibility="visible" />

我已经删除了weight=1属性,但它不起作用。如何解决此问题?


<EditText
    android:id="@+id/mylist_AddNewFFtext"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:layout_weight="1"
    android:background="@drawable/mylist_stdcenterelement"
    android:imeOptions="actionSend|actionGo|actionDone"
    android:inputType="text|textCapWords"
    android:maxLength="1000"
    android:padding="5dp"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    android:textStyle="bold"
    android:visibility="visible" />

将布局高度设为0dp以包装内容,因为您正试图将文本插入0dp高度编辑文本框

将宽度和高度更改为“包装父对象”,这意味着视图将刚好足够大,可以包含其内容。然后在开始键入之前,编辑框的大小将为零?不,它不会为零!试试这个。是的,尺寸不是零…但它不能解决我的问题:(这就是为什么我给重量属性。