0

在屏幕上,我在顶部有一个编辑文本(大包含4-5行的空格),下方是图像视图,底部是提交按钮。在键盘上它不应该隐藏我的提交按钮。部分用户界面屏幕向上

当键盘出现时,我可以使用android:windowSoftInputMode="adjustResize"来调整窗口的大小,它允许我不隐藏提交按钮,但它调整了我的图像也是我不想要的。

只有提交按钮应该向上移动时键盘可见而不调整图像大小。

我也试过帧布局,但它并没有可能是我尝试错误的方式。任何帮助将appriciated。

回答

1

应用这个,让我知道它还在发生与否。

activity_mian.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_vertical|center_horizontal" 
    android:background="@drawable/xxx.jpg" 
    android:orientation="vertical" 
    tools:context=".LoginActivity" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical|center_horizontal" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="match_parent" 
      android:layout_height="190dp" 
      android:layout_marginTop="20dp" 
      android:src="@drawable/logo_app" /> 

     <EditText 
      android:id="@+id/edtEmail" 
      android:layout_width="wrap_content" 
      android:layout_height="50dp" 
      android:layout_gravity="center_vertical|center_horizontal" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/login_textbox" 
      android:ems="10" 
      android:hint="Email" 
      android:imeOptions="actionNext" 
      android:inputType="textEmailAddress" 
      android:singleLine="true" 
      android:textColor="#ffffff" 
      android:textCursorDrawable="@null" /> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <EditText 
       android:id="@+id/edtPassword" 
       android:layout_width="wrap_content" 
       android:layout_height="50dp" 
       android:layout_gravity="center_vertical|center_horizontal" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:background="@drawable/login_textbox" 
       android:ems="10" 
       android:hint="Password" 
       android:imeOptions="actionDone" 
       android:inputType="textPassword" 
       android:singleLine="true" 
       android:textColor="#ffffff" 
       android:textCursorDrawable="@null" /> 

      <ImageView 
       android:id="@+id/imageView2" 
       android:layout_width="40dp" 
       android:layout_height="40dp" 
       android:layout_alignParentTop="true" 
       android:layout_alignRight="@+id/edtPassword" 
       android:layout_marginTop="2dp" /> 
     </RelativeLayout> 

     <CheckBox 
      android:id="@+id/checkBox_remember" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginTop="20dp" 
      android:button="@drawable/checkbox_selector" 
      android:checked="true" 
      android:focusable="false" 
      android:focusableInTouchMode="true" 
      android:text=" Remember Me" 
      android:textColor="#ffffff" />  


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="15dp" 
      android:layout_marginRight="15dp" 
      android:layout_marginTop="10dp" 
      android:orientation="vertical" > 

      <Button 
       android:id="@+id/btnLogin" 
       android:layout_width="wrap_content" 
       android:layout_height="50dp" 
         android:layout_gravity="top|center_vertical|center_horizontal" 
       android:layout_marginTop="10dp" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="20dp" 
       android:background="@drawable/btn_login" /> 


     </LinearLayout> 


    </LinearLayout> 

</ScrollView> 

设置你的按钮,EditText上等内,随后由一位家长滚动型一个线性布局。

彼此的事情是,设置机器人:windowSoftInputMode =“stateAlwaysHidden” 你的java文件中在您的XML文件进行绑定。

+0

感谢有了一些变化,它的工作您的解决方案= “adjustResize”所以请编辑答案。 – CodingRat

+0

善意的除了答案,如果它使用完全你。@ CodingRat – Radhey

+0

1)根本布局正常在我的情况相对布局。然后在滚动视图内滚动视图采用线性布局,其中指定编辑文本+图像视图。然后底部按钮。 – CodingRat

1

随着@jigs一些改变答案,我得到它的工作和发布可能是它可以帮助别人像我一样

1)根布局为正常在我的情况相对布局。然后在滚动视图内滚动视图采用线性布局,其中指定编辑文本+图像视图。然后底部按钮。

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/root_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?android:attr/actionBarSize" 
    android:background="@android:color/white" 
    android:orientation="vertical"> 

<ScrollView 
    android:id="@+id/scrollViewNotScrollable" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@id/user_name_container"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center_vertical" 
     android:orientation="vertical" 

     > 

     <EditText 
      android:id="@+id/input_feed" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:background="#00000000" 
      android:ellipsize="start" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:gravity="start|center_vertical" 
      android:hint="@string/feed_hint" 
      android:imeActionLabel="Submit" 
      android:imeOptions="actionSend" 
     android:inputType="textMultiLine|textAutoCorrect|textCapSentences" 
      android:maxLines="5" 
      android:minLines="3" 
      android:paddingLeft="5dp" 
      android:paddingRight="5dp" 
      android:paddingTop="25dp" 
      android:textColor="@color/feed_sub_color" 
      android:textColorHint="@color/light_gray" 
      android:textCursorDrawable="@null" /> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dp"> 
      <!--<ScrollView 
       android:id="@+id/scroll" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:isScrollContainer="false" 
       android:padding="4dp" 

       android:layout_centerHorizontal="true" 
       >--> 
      <ImageView 
       android:id="@+id/imgPreview" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_gravity="center" 
       android:layout_marginBottom="20dp" 
       android:layout_marginTop="20dp" 
       android:adjustViewBounds="true" 
       android:background="@android:color/white" 
       android:elevation="5dp" 
       android:padding="4dp" 
       android:visibility="gone" /> 
      <!--</ScrollView>--> 
      <ImageView 
       android:id="@+id/close_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignTop="@+id/imgPreview" 
       android:layout_marginLeft="-45dp" 
       android:layout_marginTop="-20dp" 
       android:layout_toRightOf="@+id/imgPreview" 
       android:elevation="5dp" 
       android:paddingBottom="15dp" 
       android:src="@drawable/closeimage" 
       android:visibility="gone" /> 

     </RelativeLayout> 
    </LinearLayout> 
</ScrollView> 

<RelativeLayout 
    android:id="@+id/user_name_container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:fitsSystemWindows="true"> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@android:color/darker_gray" /> 

    <EditText 
     android:id="@+id/feed_user_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:background="@null" 
     android:ellipsize="end" 
     android:fontFamily="san-serif-condensed" 
     android:padding="12dp" 
     android:singleLine="true" 
     android:text="sherry's phone" 
     android:textColor="@android:color/black" 
     android:textSize="@dimen/feed_name_size" 
     android:visibility="gone" /> 

    <TextView 
     android:id="@+id/feed_user_name_textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:background="@null" 
     android:ellipsize="end" 
     android:fontFamily="san-serif-condensed" 
     android:padding="12dp" 
     android:paddingLeft="20dp" 
     android:singleLine="true" 
     android:text="sherry's phone" 
     android:textColor="@android:color/black" 
     android:textSize="@dimen/feed_name_size" /> 

    <ImageView 
     android:id="@+id/edit_name" 
     android:layout_width="wrap_content" 
     android:layout_height="30dp" 
     android:layout_alignParentRight="true" 
     android:layout_gravity="end" 
     android:layout_marginBottom="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:paddingBottom="5dp" 
     android:paddingTop="5dp" 
     android:scaleType="centerInside" 
     android:src="@drawable/editname" /> 

    <Button 
     android:id="@+id/done" 
     android:layout_width="wrap_content" 
     android:layout_height="30dp" 
     android:layout_alignParentRight="true" 
     android:layout_marginBottom="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/rounded_corner_update_block" 
     android:fontFamily="san-serif-medium" 
     android:text="Done" 
     android:textColor="@android:color/white" 
     android:visibility="gone" /> 
</RelativeLayout> 

</RelativeLayout> 

2)安卓windowSoftInputMode在你的manifest.xml

3)禁用滚动在Java代码(可选)

mScrollView.setOnTouchListener(new OnTouchListener() { 

      @Override 
      public boolean onTouch(View v, MotionEvent event) 
      { 
        return true; 
      } 
}); 
相关问题