Android编辑文本展开为对话框
我有这个布局Android编辑文本展开为对话框,android,android-edittext,landscape,expand,Android,Android Edittext,Landscape,Expand,我有这个布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/viewer_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/background_dark"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="3dp"
android:layout_weight="1" >
<EditText
android:id="@+id/viewer_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_filter"
android:background="@android:color/white"
android:drawableLeft="@android:drawable/ic_menu_search"
android:inputType="text"
android:paddingLeft="4dp"
android:selectAllOnFocus="true" >
</EditText>
<ImageView
android:id="@+id/viewer_filterX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/viewer_filter"
android:layout_alignRight="@id/viewer_filter"
android:src="@android:drawable/ic_menu_close_clear_cancel"
android:visibility="invisible" >
</ImageView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<EditText
android:id="@+id/viewer_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_search"
android:background="@android:color/white"
android:drawableLeft="@android:drawable/ic_menu_search"
android:inputType="text"
android:paddingLeft="4dp"
android:selectAllOnFocus="true" >
</EditText>
<ImageView
android:id="@+id/viewer_searchGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/viewer_search"
android:layout_alignRight="@id/viewer_search"
android:src="@android:drawable/ic_menu_send"
android:visibility="invisible" >
</ImageView>
<ImageView
android:id="@+id/viewer_searchX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/viewer_search"
android:layout_toLeftOf="@id/viewer_searchGo"
android:src="@android:drawable/ic_menu_close_clear_cancel"
android:visibility="invisible" >
</ImageView>
</RelativeLayout>
</LinearLayout>
<HorizontalScrollView
android:id="@+id/viewer_hscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/viewer_top" >
<ListView
android:id="@+id/viewer_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</HorizontalScrollView>
</RelativeLayout>
当我单击其中一个EditText时,它会扩展到以下对话框:
在纵向模式下,编辑文本可以按原样编辑,无需展开。肖像的XML是类似的,只有EditText是一个在另一个之下,并且是屏幕宽的
如何防止此EditText扩展?EditText+虚拟键盘不仅隐藏了整个手机屏幕,而且我放在EditText上的可点击图像也不可见
- 我试图将EditText布局宽度设置为0dp,但它们没有显示
- 我没有使用SearchView,因为它们窃取了焦点,我无法使用back键返回到上一个活动
我删除了layout land XML,并对纵向和横向使用了相同的XML。
在纵向模式下,没有扩展,在横向模式下有扩展。
因此,这与处于横向模式有关。尝试使用
android:maxLines=“1”
编辑文本我也有类似的问题。您可以使用mEditText.setSingleLine(true);你在哪里使用它。这将解决您的问题。解决了相同的问题,并提供了解决方案
需要添加
android:imeOptions="flagNoExtractUi"
以防止这种行为
如果有人知道怎么做,请将这篇文章标记为重复。嗨,请在java代码中添加这一行,其中声明编辑文本description.setMaxLines(1)将此行添加到编辑文本中
android:imeOptions="flagNoFullscreen"
编辑文本,如下所示
<EditText
android:id="@+id/viewer_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint_filter"
android:background="@android:color/white"
android:drawableLeft="@android:drawable/ic_menu_search"
android:inputType="text"
android:paddingLeft="4dp"
android:selectAllOnFocus="true"
android:imeOptions="flagNoFullscreen">
为其创建布局landscape@shreeshas这是横向布局,我写道纵向的XML类似,但不同。请尝试在清单中使用android:WindowsOfInputMode=“adjustPan | stateHidden”参数file@itsrajesh4uguys我发布了解决方案,它是IME属性。刚刚尝试过,no changeTreated与setSingleLine()和setSingleLine(true)相同,no change此解决方案已发布,不起作用。::我已经发布了正确的解决方案。