在键盘不工作时按下活动内容

时间:2018-02-08 09:15:02

标签: android android-layout

我尝试在android:windowSoftInputMode文件和

中添加AndroidManifest.xml
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

他们都没有工作。甚至尝试从堆栈Overflow中添加一些WorkAround代码。没有任何变化。

在我的xml中,我使用了包含在ScrollView下的RelativeLayout。 scrollview只包含一个子节点,即RelativeLayout

请帮我做。我长期坚持这个问题。

  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:fillViewport="true">

   <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorWhite"
    android:focusable="true"
    android:focusableInTouchMode="true"
    tools:context="ca.com.helptree.Activities.LoginActivity">

    <ImageView
        android:id="@+id/imglogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="62dp"
        app:srcCompat="@drawable/appicon" />

    <TextView
        android:id="@+id/txtAppName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imglogo"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:text="@string/app_Uname"
        android:textColor="@color/colorBlack"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/tvCCode"
        android:layout_width="70dp"
        android:layout_height="30dp"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/txtAppName"
        android:layout_marginStart="25dp"
        android:layout_marginTop="26dp"
        android:background="@xml/rounded_corner"
        android:ems="10"
        android:gravity="center"
        android:hint="+Code"
        android:text=""
        android:textAlignment="center"
        android:textColor="@color/colorBlack" />


    <EditText
        android:id="@+id/etxtMobileNo"
        android:layout_width="225dp"
        android:layout_height="30dp"
        android:layout_alignTop="@+id/tvCCode"
        android:layout_marginStart="26dp"
        android:layout_toEndOf="@+id/tvCCode"
        android:background="@xml/rounded_corner"
        android:ems="10"
        android:gravity="center"
        android:hint="Mobile No"
        android:inputType="phone"
        android:textColor="@color/colorBlack" />

    <android.support.design.widget.TextInputLayout
        android:id="@+id/txtILayout"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:layout_alignEnd="@+id/etxtMobileNo"
        android:layout_below="@+id/tvCCode"
        android:layout_marginStart="25dp"
        android:layout_marginTop="13dp"
        android:textAlignment="center"
        app:hintEnabled="false"
        app:passwordToggleEnabled="true">

        <EditText
            android:id="@+id/etxtPassword"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@xml/rounded_corner"
            android:gravity="center"
            android:hint="Password"
            android:inputType="textPassword"
            android:textAlignment="center"
            android:textColor="@color/colorBlack" />
    </android.support.design.widget.TextInputLayout>

    <Button
        android:id="@+id/btnSignup"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_alignStart="@+id/txtILayout"
        android:layout_below="@+id/txtILayout"
        android:layout_marginTop="11dp"
        android:background="@xml/signup_button"

        android:text="@string/Signup"
        android:textColor="@color/colorWhite" />

    <Button
        android:id="@+id/btnSignin"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/txtILayout"
        android:layout_alignTop="@+id/btnSignup"
        android:background="@xml/signin_button"

        android:text="@string/Signin"
        android:textColor="@color/colorWhite" />
  </RelativeLayout></ScrollView>

1 个答案:

答案 0 :(得分:0)

在AndroidManifest.xml文件中放置最后一行

<activity
        android:name="at.next.neah.screens.service.activitys.MY_Activity"
        android:configChanges="orientation|screenSize|keyboardHidden"
        android:launchMode="singleTop"
        android:windowSoftInputMode="adjustResize" /> <<<<<<<<<<<<<<<
相关问题