简体   繁体   English

当软键盘打开时,片段内的EditText被隐藏

[英]EditText inside a fragment is Hidden when soft keyboard opens

My Activity contains two fragments , at the bottom a control bar and above it this layout with two EditText: 我的Activity包含两个片段,底部是一个控制栏,在它上面有两个EditText:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/invested_grey_color" >

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="5dp"
    android:background="@color/transperent_black" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/choose_a_set_LeagueName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/view_tournament_rules"
        android:textColor="@color/white"
        android:textSize="20sp" />

    <ImageView
        android:id="@+id/choose_a_set_view_tournamnet_rules_iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:layout_toLeftOf="@+id/choose_a_set_LeagueName"
        android:clickable="true"
        android:src="@drawable/question" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/Choose_a_set_rl"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/relativeLayout1"
    android:layout_marginTop="15dp"
    android:background="@color/transperent_sportzone_green" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/choose_a_set_stage_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/choose_a_set"
        android:textColor="@color/sportzone_green"
        android:textSize="35sp" />

    <ImageView
        android:id="@+id/choose_a_set_vi_sign_iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="20dp"
        android:src="@drawable/ic_launcher" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/make_it_your_own"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/Choose_a_set_rl"
    android:layout_marginTop="1dp"
    android:background="@color/transperent_sportzone_green" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/make_it_your_own_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/make_it_your_own"
        android:textColor="@color/sportzone_green"
        android:textSize="35sp" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/add_tournament_name_ll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/edit_text_wraper"
    android:layout_marginTop="14dp"
    android:background="@color/add_tournament_red_color"
    android:visibility="invisible" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/information_to_user_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="3dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="3dp"
        android:text="@string/add_tournamnet_name"
        android:textColor="@color/white"
        android:textSize="20sp" />
</LinearLayout>

<RelativeLayout
    android:id="@+id/tournamnet_make_it_your_own_next_btn"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="5dp"
    android:layout_below="@+id/add_tournament_name_ll"
    android:background="@color/transperent_black"
    android:clickable="true"
    android:enabled="false" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/make_iyt_your_own_next_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="30dp"
        android:text="@string/next"
        android:textColor="@color/disables_btn_text_color"
        android:textSize="@dimen/next_btn_font" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/invite_friends_rl"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/tournamnet_make_it_your_own_next_btn"
    android:background="@color/transperent_sportzone_green" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/invites_friends_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/invite_your_friends"
        android:textColor="@color/sportzone_green"
        android:textSize="35sp" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/edit_text_wraper"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/make_it_your_own" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="20dp"
        android:text="@string/tournament_name"
        android:textColor="@color/white"
        android:textSize="30sp" />

    <EditText
        android:id="@+id/tournament_name_et"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginRight="20dp"
        android:background="@drawable/rounded_et"
        android:ems="10"
        android:inputType="text"
        android:maxLength="30"
        android:paddingLeft="20dp"
        android:textSize="30sp" >

        <requestFocus />
    </EditText>

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tournament_name_et"
        android:layout_below="@+id/tournament_name_et"
        android:layout_marginTop="26dp"
        android:text="@string/jeckpot"
        android:textColor="@color/white"
        android:textSize="30sp" />

    <EditText
        android:id="@+id/jeckpot_amont_et"
        android:layout_width="220dp"
        android:layout_height="50dp"
        android:layout_alignLeft="@+id/textView2"
        android:layout_below="@+id/textView2"
        android:background="@drawable/rounded_et"
        android:ems="10"
        android:inputType="number"
        android:maxLength="9"
        android:paddingLeft="20dp"
        android:textSize="35sp" />

    <ImageView
        android:id="@+id/tournamentt_type_instructions_iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/jeckpot_amont_et"
        android:layout_alignRight="@+id/tournament_name_et"
        android:clickable="true"
        android:src="@drawable/question" />

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/tournamentt_type_instructions_iv"
        android:layout_toRightOf="@+id/textView1"
        android:text="@string/tournament_type"
        android:textColor="@color/white"
        android:textSize="30sp" />

    <Switch
        android:id="@+id/basic_expert_switcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/jeckpot_amont_et"
        android:layout_alignBottom="@+id/jeckpot_amont_et"
        android:layout_toRightOf="@+id/textView1"
        android:textOff="@string/basic"
        android:textOn="@string/expert"
        android:thumb="@drawable/thumb_selector"
        android:track="@drawable/switch_bg" />

</RelativeLayout>

the problem is when the uses taps on the second EditText the keyboard hides it and the user can't see what he is typing. 问题是当用户点击第二个EditText键盘时,键盘隐藏它并且用户无法看到他正在键入的内容。 i worked on it for to long... i have added 我工作了很长时间......我补充说

android:windowSoftInputMode="adjustResize"

and adjustpan in Manifest file , none of them helped. 和Manifest文件中的adjustpan ,没有一个帮助。

any ideas? 有任何想法吗?

Put this line inside oncreate, 将此行放在oncreate中,

 getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

你也可以把这一行放在清单上

   android:windowSoftInputMode="adjustResize|stateHidden"

I was having a similar problem and adding this to the manifest worked for me. 我遇到了类似的问题,并将此添加到清单中为我工作。

<activity
    ...
    android:windowSoftInputMode="adjustPan"/>

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

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