简体   繁体   English

在Android中打开软键盘时未显示“编辑文本”

[英]Edit Text is not showing while opening the soft keyboard in android

I have created an activity. 我创建了一个活动。 It's working fine. 一切正常。 But when i try to take input through the edit text. 但是当我尝试通过编辑文本进行输入时。 I am selecting the edit text, then the edit text gets hidden by the soft keyboard. 我选择了编辑文本,然后编辑文本被软键盘隐藏。

I have tried by giving the android:windowSoftInputMode="adjustPan" and android:windowSoftInputMode="adjustResize" permission, but its not getting solved. 我已经尝试通过赋予android:windowSoftInputMode="adjustPan"android:windowSoftInputMode="adjustResize"权限来android:windowSoftInputMode="adjustResize" ,但仍未解决。 please help me to resolve this issue guys. 请帮我解决这个问题。

Here is my screen when the activity is shown. 显示活动时,这是我的屏幕。

最初看起来像这样

And it shown like this when the edit text is selected. 当选择编辑文本时,它显示如下。

在此处输入图片说明

You can see in the above image,the edit text is gets hidden, thats why i am unable to enter the text inside that. 您可以在上图中看到,编辑文本被隐藏,这就是为什么我无法在其中输入文本。 please help me resolve this. 请帮助我解决这个问题。

This is my layout.xml 这是我的layout.xml

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/textViewOSoutletName"
        style="@style/HeadingTheme"
        android:drawableRight="@drawable/transaction"
        android:paddingBottom="0dp"
        android:paddingRight="10dp"
        android:text="@string/outletname" >
    </TextView>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="@color/black_dark" >
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1" >

    <TextView
        android:id="@+id/textViewOSBrand"
        style="@style/Head_Text"
        android:layout_weight="0.2"
        android:text="@string/brand"
        android:textSize="25dp" />

    <Spinner
        android:id="@+id/spinnerOSBrandName"
        style="@style/Style_Spinner"
        android:layout_height="50dp"
        android:layout_weight="0.8" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:layout_marginTop="2dp"
    android:background="@color/black_dark" >
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1" >

    <TextView
        android:id="@+id/textViewOScategory"
        style="@style/Head_Text"
        android:layout_weight="0.2"
        android:text="@string/category"
        android:textSize="25dp" />

    <Spinner
        android:id="@+id/spinnerOScategoryName"
        style="@style/Style_Spinner"
        android:layout_height="50dp"
        android:layout_weight="0.8" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:layout_marginTop="2dp"
    android:background="@color/black_dark" >
</LinearLayout>

<TextView
    android:id="@+id/textViewOSProductNameHeading"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:gravity="center"
    android:singleLine="true"
    android:text="@string/product_name"
    android:textColor="@color/blue"
    android:textSize="25dp" />
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="vertical"
    android:layout_weight="1.0">
 <HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:fadingEdge="none"
    android:fillViewport="true"
    android:scrollbars="none" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="@color/grey_default"
        android:weightSum="1" >

        <TextView
            android:id="@+id/textViewOSProductName"
            style="@style/ListViewHeaderThemeLarge"
            android:layout_width="0dp"
            android:layout_weight="0.5"                
            android:text="@string/product_name" />

        <ImageView
            android:id="@+id/imageViewseparator1"
            style="@style/ListViewHeaderSeperator" />

        <TextView
            android:id="@+id/textViewOSQuantity"
            style="@style/ListViewHeaderThemeLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:gravity="center"
            android:text="@string/qty" />

        <ImageView
            android:id="@+id/imageViewseparator2"
            style="@style/ListViewHeaderSeperator" />

        <TextView
            android:id="@+id/textViewOSPrice"
            style="@style/ListViewHeaderThemeLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:gravity="center"
            android:text="@string/rp" />           
    </LinearLayout>

</HorizontalScrollView>
 <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
         <ListView
            android:id="@+id/listViewOS"
            style="@style/ListViewTheme"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </ListView>
    </LinearLayout>
    </LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/footer_background_drawable"
    android:gravity="center"
    android:orientation="vertical" >

    <View
        style="@style/horizontalImg"
        android:background="@color/black_dark" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:orientation="horizontal"
        android:weightSum="1" >

        <Button
            android:id="@+id/buttonOSBack"
            style="@style/styleNormalButtonLargeLand"
            android:drawableLeft="@drawable/left"
            android:text="@string/back" >
        </Button>

        <Button
            android:id="@+id/buttonOSSubmit"
            style="@style/styleNormalButtonLargeLand"
            android:drawableRight="@drawable/discount1"
            android:text="@string/discount" >
        </Button>
    </LinearLayout>


</LinearLayout>

And this is my layout for creating the list elements. 这是我用于创建列表元素的布局。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1"
        android:background="@drawable/list_selector" >

        <TextView
            android:id="@+id/textViewOSLProductName"
            style="@style/ListViewTextViewLarge"
            android:layout_width="0dp"
            android:layout_weight="0.5"
            android:ellipsize="end"
            android:gravity="left"
            android:paddingLeft="3dp"
            android:singleLine="true"
            android:text="@string/product_name"
            android:textColor="@drawable/text_selector" />

        <ImageView
            android:id="@+id/imageViewselparator1"
            style="@style/ListViewTextSeperatorForAll" />

        <EditText
            android:id="@+id/editTextOSLQuantity"
            style="@style/ListViewTextViewLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:background="#FBFCFE"
            android:gravity="center"
            android:inputType="number"
            android:maxLength="5"
            android:text="qty"
            android:textStyle="bold"
            android:textColor="@color/black_dark" />
        <!-- android:background="#404040" -->

        <ImageView
            android:id="@+id/imageViewselparator2"
            style="@style/ListViewTextSeperatorForAll" />

        <TextView
            android:id="@+id/textViewOSLPrice"
            style="@style/ListViewTextViewLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:gravity="center"
            android:maxLength="8"
            android:text="rp"
            android:textColor="@drawable/text_selector" />
    </LinearLayout>

</LinearLayout>

Thanks in advance. 提前致谢。

Inside your Android manifest file, you had to set this tag in your desired activity 在您的Android清单文件中,您必须在所需的活动中设置此标签

android:windowSoftInputMode="adjustPan"

And Let me know if it works 让我知道是否可行

尝试ScrollView添加android:layout_gravity="center"

This is an Android issue (see link below) and happens in fullscreen, ie when there is no statusbar. 这是一个Android问题(请参见下面的链接),并且在全屏模式下发生,即没有状态栏时。 Try your app in non-fullscreen. 在非全屏模式下尝试您的应用。

Android issue: http://code.google.com/p/android/issues/detail?id=10510 Android问题: http//code.google.com/p/android/issues/detail?id = 10510

Edit: Fullscreen flags - you should remove these if you have them. 编辑:全屏标志-如果有标志,则应将其删除。

requestWindowFeature(Window.FEATURE_NO_TITLE); // removes title
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // removes statusbar

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

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