2017-05-05 39 views
0

像下面显示的图像我的活动正在查看像第二个图像。如何解决此问题。当查看碎片中的软键盘时,顶部相对布局是隐藏的吗?

enter image description here我面临的问题是,当按下软键盘时,顶部相对布局被隐藏,并且回收站视图被放置在相对布局下面,我完全看到了屏幕。如何解决这个问题。我搜遍了堆栈溢出,但问题没有解决。

XML代码连接下面

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg" 
    > 


    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white" 
     android:layout_marginTop="?android:attr/actionBarSize"> 

     <com.onefitstop.utility.CustomTextViewBold 
      android:id="@+id/chat_activity_label" 
      android:layout_width="match_parent" 
      android:layout_height="40dp" 
      android:background="@color/white_partial" 
      android:gravity="center_vertical" 
      android:paddingLeft="10dp" 
      android:text="@string/chat_activity" 
      android:textStyle="bold" 
      android:textAllCaps="true" 
      android:textColor="@color/text_voiletlight" 
      android:textSize="18sp" /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler_view_chat_list" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/chat_activity_label" 
      android:scrollbars="vertical" /> 
    </RelativeLayout> 


     <include layout="@layout/error_screen"></include> 

</RelativeLayout> 

所包含的布局error_screen.xml

<?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" 
    android:visibility="gone" 
    android:background="@color/white" 
    android:id="@+id/layoutError"> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:minHeight="200dp" 
       android:layout_gravity="center" 
       android:src="@drawable/ic_error_1" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="vertical"> 

      <com.onefitstop.utility.CustomTextView 
       android:id="@+id/txtErrorMsg" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="@string/error_msg" 
       android:textColor="@color/text_voiletlight" 
       android:textSize="24sp" 
       android:textStyle="bold" /> 

      <com.onefitstop.utility.CustomButton 
       android:id="@+id/btnRefresh" 
       android:layout_width="match_parent" 
       android:layout_height="40dp" 
       android:layout_marginLeft="80dp" 
       android:layout_marginRight="80dp" 
       android:layout_marginTop="40dp" 
       android:gravity="center" 
       android:text="Refresh" 
       android:textColor="@color/text_grey" 
       android:background="@drawable/refresh_button" 
       android:textSize="15sp" /> 
       </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 
+0

后发生的屏幕截图。 –

+0

和你想做什么写,以及 – Drim

+0

当键盘被按下顶部布局被隐藏 –

回答

0

尝试设置android:windowSoftInputMode="adjustResize"<activity>的清单。查看更多信息here

+0

我试过这种方法,但软键盘只是查看ediitext不可见 –

+0

你可以有一个或另一个。在一种情况下,屏幕的顶部是隐藏的,您可以看到EditText,或者在另一个屏幕中,您可以看到屏幕的顶部,但键盘可能位于EditText的顶部。 如果您希望用户能够看到屏幕的顶部和EditText,您可以将您的布局放入ScrollView并实施第一种情况。因此,如果需要,用户可以滚动查看屏幕的顶部,并且EditText不会隐藏。 – Eselfar

+0

是否有任何可能的方法来查看编辑文本而不使用滚动视图 –