2017-05-22 33 views
0

我的界面看起來是這樣的:如何防止FrameLayout遮擋我的視圖?

enter image description here

XML:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <LinearLayout 
      android:id="@+id/profile_fields_container" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginTop="20dp" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/account_person_name_label" /> 

      <EditText 
       android:id="@+id/person_name" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:minWidth="150dp"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="@string/account_person_emailId_label" /> 
      <EditText 
       android:id="@+id/person_emailId" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:inputType="textEmailAddress" 
       android:minWidth="150dp"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="@string/account_person_phoneNo_label" /> 
      <EditText 
       android:id="@+id/person_phoneNo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:inputType="phone" 
       android:maxLength="10" 
       android:minWidth="150dp"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="@string/account_person_password_label" /> 
      <EditText 
       android:id="@+id/password" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:inputType="textPassword" 
       android:minWidth="150dp"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="@string/account_person_retypePassword_label" /> 
      <EditText 
       android:id="@+id/retype_password" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:inputType="textPassword" 
       android:minWidth="150dp"/> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:layout_marginTop="20dp"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/learner_tutor_status_label" /> 

       <android.support.v7.widget.AppCompatSpinner 
        android:id="@+id/learner_tutor_status_spinner" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"/> 

      </LinearLayout> 

     </LinearLayout> 

    </ScrollView> 

    <!--Floating Button--> 
    <Button 
     android:id="@+id/create_account" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:text="@string/create_account_string" 
     style="@style/Widget.AppCompat.Button.Colored"/> 

</FrameLayout> 

現在,你可以在底部看到有我在這裏...。這是一個下拉列表,當我選擇其中一個選項時,我的代碼會動態地向層次結構添加一些視圖,但問題是它們不可見(不是全部;只是我是...是可見的)

我通過佈局檢查器檢查了佈局層次結構,結果表明層次結構處於活動狀態,但浮動按鈕(創建帳戶)掩蓋了它。現在

,我知道,如果我是一個LinearLayout更換根FrameLayout,這將是可見的,但問題是,如果然後我會點擊一個EditText按鈕,鍵盤將涵蓋與創建帳戶按鈕,屏幕也包括在內。 我真的希望這個按鈕始終在屏幕上。

有沒有人可以解決這個問題?

回答

0

您的佈局並不完全正確,因爲您的浮動按鈕一直隱藏着您的ScrollView的底部。您應該將FrameLayout替換爲垂直LinearLayout(就像您所說的),然後在AndroidManifest.xml文件的activity元素中彈出軟鍵盤windowSoftInputMode屬性時指定活動的窗口行爲。如果使用android:windowSoftInputMode="adjustResize",則窗口將相應地調整大小,並且該按鈕應始終可見。