2017-05-15 56 views
0

我面臨的問題是,當軟鍵盤出現時,活動頂部的框架佈局被推高。框架佈局放置在線性佈局內,並且在滾動視圖下方放置多個edittext。我已經嘗試了在堆棧溢出發佈的答案,但仍然沒有解決我的問題。 我在目標sdk版本25和最小版本16中創建應用程序。當軟鍵盤出現時,如何避免框架佈局被推高?

我將`below方法應用於AndroidManifestFile中的活動。

<activity android:name=".Activities.ScamLookUpActivity" 
      android:configChanges="keyboard|keyboardHidden|screenSize|screenLayout|" 
      android:screenOrientation="portrait" 
      android:windowSoftInputMode="adjustResize"/>` 

我不知道如何解決這個錯誤,並告訴爲什麼給定的方法不適用於我的活動的原因。

這是我的XML佈局文件...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/activity_scam_look_up" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="#eee" 
tools:context="com.zcodia.scamlookup.Activities.ScamLookUpActivity"> 

<FrameLayout 
    android:id="@+id/frameLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 

    <View 
     android:layout_width="match_parent" 
     android:layout_marginTop="20dp" 
     android:layout_height="?android:attr/actionBarSize" 
     android:background="@mipmap/bg_splash_cut"> 


    </View> 
    <View 
     android:layout_width="match_parent" 
     android:layout_height="25dp" 
     android:alpha="1" 
     android:background="#A82A37" /> 
    <TextView 
     android:id="@+id/left_buton" 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_marginLeft="12dp" 
     android:layout_marginTop="30dp" 
     android:text="@string/menu" 
     android:textSize="30dp" 
     android:gravity="center" 
     android:textColor="#FFF"/> 

    <com.zcodia.scamlookup.Utils.CustomTextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Scam lookup" 
     android:layout_marginTop="29dp" 
     android:layout_marginLeft="60dp" 
     android:textSize="20dp" 
     android:textColor="#FFF" 
     android:gravity="center"/> 

</FrameLayout> 

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

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="#f9f9f9" 
    android:focusableInTouchMode="true" 
    android:paddingBottom="20dp"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:paddingBottom="10dp" 
    android:background="@drawable/text_input2" 
    > 

    <com.zcodia.scamlookup.Utils.CustomTextView 
     android:text="Search Scam Database" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="10dp" 
     android:id="@+id/textView4" 
     android:textSize="20dp" 
     android:textColor="#000" 
     android:layout_below="@+id/linearLayout" 
     android:typeface="sans" 
     /> 

    <com.zcodia.scamlookup.Utils.CustomTextView 
     android:text="Contact Medium" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/textView4" 
     android:layout_marginLeft="10dp" 
     android:id="@+id/details_id" 
     android:textColor="#D32F2F" 
     android:typeface="sans" 
     android:textSize="15dp" 
     android:layout_marginTop="10dp"/> 


    <android.support.v7.widget.RecyclerView 
     android:layout_width="wrap_content" 
     android:layout_height="60dp" 
     android:id="@+id/recyclerView" 
     ></android.support.v7.widget.RecyclerView> 


</LinearLayout> 

<com.zcodia.scamlookup.Utils.CustomTextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Category" 
    android:id="@+id/textView5" 
    android:layout_below="@+id/linearLayout2" 
    android:layout_marginTop="10dp" 
    android:layout_marginLeft="15dp" 
    android:textColor="#D32F2F" 
    android:textSize="15dp" 
    /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="10dp" 
    android:orientation="vertical" 
    android:paddingBottom="20dp" 
    android:id="@+id/relative_spinner" 
    android:focusableInTouchMode="true"> 


    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="15dp" 
     android:background="@drawable/textinput" 
     android:layout_marginRight="10dp"> 

    <Spinner 

     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_alignParentTop="true" 
     android:id="@+id/categorySpinner" 
     android:text="@string/inheritance" 
     android:prompt="@string/inheritance" 
     android:paddingLeft="0dp" 
     /> 

    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="15dp" 
     android:background="@drawable/textinput" 
     android:layout_marginRight="10dp"> 

     <Spinner 

      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_marginTop="1dp" 
      android:id="@+id/categorySpinner2" 
      android:text="@string/inheritance" 
      android:prompt="@string/inheritance" 
      android:paddingLeft="0dp" 
      /> 

    </RelativeLayout> 

    <com.zcodia.scamlookup.Utils.CustomEditText 
     android:inputType="phone" 
     android:id="@+id/phoneNumber_editText" 
     android:hint="@string/phonenumber" 
     android:typeface="sans" 
     style="@style/CustomFontStyle" 
     android:layout_marginTop="20dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 


    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp"> 

     <AutoCompleteTextView 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_marginLeft="0dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="0dp" 
      android:id="@+id/yourLocation" 
      android:hint="Location" 
      android:textColorHint="#757575" 
      style="@style/CustomFontStyle"/> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="330dp" 
      android:text="&#xf041;" 
      android:id="@+id/scammer_location_font" 
      android:textColor="#3eb3a0" 
      android:textSize="25dp" 
      android:layout_marginTop="10dp"/> 

    </RelativeLayout> 

    <com.zcodia.scamlookup.Utils.CustomEditText 
     android:inputType="textPersonName" 
     android:hint="@string/scammer_location" 
     android:id="@+id/scammerLocation_editText" 
     android:typeface="sans" 
     style="@style/CustomFontStyle" 
     android:layout_marginTop="20dp" 
    /> 

    <com.zcodia.scamlookup.Utils.CustomEditText 

     android:inputType="textPersonName" 
     android:hint="@string/keyWord" 
     android:id="@+id/keyword_edittext" 
     android:background="@drawable/textinput" 
     android:typeface="sans" 
     style="@style/CustomFontStyle" 
     android:layout_marginTop="20dp" 
     /> 

</LinearLayout> 

    <com.wefika.flowlayout.FlowLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/clip_flow_layout" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp"> 

    </com.wefika.flowlayout.FlowLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     > 

     <com.zcodia.scamlookup.Utils.CustomButton 
      android:text="Search" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/search_id" 
      android:background="@mipmap/bg_splash_cut" 
      android:textColor="#FFFFFF" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp"/> 


    </LinearLayout> 

</ScrollView> 

下面的圖片是我的活動。

enter image description here

當的EditText按下頂部框架佈局

被向上推。

enter image description here

回答

0

此屬性適用於您的滾動視圖:android:fitsSystemWindows="true",並依照本

link

+0

還沒解決的問題 –

+0

u可以使用線性佈局而不是框架佈局。 –

+0

我試了一下,但沒有工作 –

1

試試這個答案,

<activity android:windowSoftInputMode="adjustPan"> </activity> 
相關問題