2016-01-16 20 views
0

即使在滾動視圖中,鍵盤覆蓋我的編輯文本和按鈕的一半也會遇到問題。即使在滾動視圖中,鍵盤也隱藏了我編輯文本和按鈕下方的一半

這裏是我的佈局,請告訴我該如何解決這個問題。他們在這個話題上有很多問題,但他們都沒有爲我工作。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:background="@drawable/bg" 
    android:layout_height="match_parent"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:fillViewport="true" 

     android:layout_height="match_parent"> 

    <RelativeLayout 

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

     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 

      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:orientation="vertical" 
      android:paddingBottom="60dp" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true"> 


      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:paddingBottom="10dp" 
       android:paddingTop="10dp"> 

       <TableRow 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="@dimen/abc_action_bar_subtitle_bottom_margin_material" 
        android:layout_marginLeft="@dimen/abc_action_bar_overflow_padding_end_material" 
        android:layout_marginRight="@dimen/abc_action_bar_overflow_padding_end_material" 
        android:layout_marginTop="@dimen/abc_action_bar_subtitle_bottom_margin_material" 
        android:background="@drawable/login_layout_bg" 
        android:paddingBottom="10dp" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingTop="10dp"> 

        <EditText 
         android:id="@+id/reg_email" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:layout_weight="1" 
         android:background="@android:color/transparent" 
         android:hint="Username" 
         android:inputType="textEmailAddress" 
         android:singleLine="true" 

         android:textColor="@color/textcolor3" 
         android:textColorHint="@color/about_libraries_card_dark" /> 

        <View 
         android:layout_width="0.5dp" 
         android:layout_height="match_parent" 
         android:background="@color/md_grey_700" /> 

        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:src="@drawable/client_icon" /> 
       </TableRow> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:paddingBottom="10dp" 
       android:paddingTop="10dp"> 

       <TableRow 
        android:id="@+id/register" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="@dimen/abc_action_bar_overflow_padding_end_material" 
        android:layout_marginLeft="@dimen/abc_action_bar_overflow_padding_end_material" 
        android:layout_marginRight="@dimen/abc_action_bar_overflow_padding_end_material" 
        android:layout_marginTop="@dimen/abc_action_bar_subtitle_bottom_margin_material" 
        android:background="@drawable/login_btn_bg" 
        android:padding="@dimen/abc_action_bar_overflow_padding_end_material"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:gravity="center" 
         android:text="Register" 
         android:textColor="@android:color/white" /> 
       </TableRow> 
      </LinearLayout> 
     </LinearLayout> 


    </RelativeLayout> 

    </ScrollView> 

</LinearLayout> 

回答

0

使用

<activity android:windowSoftInputMode="adjustPan" > 

您也可以參考here更多的澄清。

+0

我已經試過但它不適用於我 –

+0

您是否嘗試刪除scrollview然後使用此設置?你需要滾動嗎? –

+0

是的,我需要滾動 –

0

在你的清單爲您的活動指定

android:windowSoftInputMode="adjustResize" 

根據docs這將有你想要的效果

活動的主窗口總是被調整以騰出空間給軟鍵盤在屏幕上。

+0

我試過這個,但它不適合我 –

+0

什麼是fillViewport?你嘗試刪除它嗎? – Desdroid

+0

是的,我也試過 –

相關問題