2013-08-05 60 views
8

我正在製作應用程序的UI。當我試圖在EditText中輸入值時,則鍵盤向上移動UI。 當鍵盤打開時請幫助我,它不應該向上移動UI。當鍵盤打開時UI向上移動

<activity 
     android:name=".AddProductsActivity" 
     android:configChanges="orientation" 
     android:hardwareAccelerated="false" 
     android:windowSoftInputMode="adjustResize" /> 

回答

12

它解決了我的問題。

感謝所有。

<activity 
    android:name=".AddProductsActivity" 
    android:configChanges="orientation" 
    android:hardwareAccelerated="false" 
    android:windowSoftInputMode="adjustPan" /> 
+0

不錯的解決方案! –

0

添加以下行的活動標籤在menifest

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
1
  1. 使用RelativeLayout的顯示頂部和另一RelativeLayout的,覆蓋整個屏幕內側底部欄。

頂級酒吧:

android:id="@+id/top" 
android:layout_alignParentTop = "true" 
android:layout_alignParentRight = "true" 
android:layout_alignParentLeft = "true" 
android:layout_width="wrap_content" 
android:layout_height="<fix height like 50dp or as per requirement>" 

的底欄:

android:id="@+id/bottom" 
android:layout_alignParentBottom="true" 

  1. 現在添加一個滾動型是這樣的:

    一ndroid:layout_width = 「WRAP_CONTENT」 機器人:layout_height = 「WRAP_CONTENT」 機器人:layout_below = 「@ + ID /頂」 機器人:layout_above = 「@ + ID /底」

  2. 現在添加子視圖這個滾動視圖,可以是任何RelativeLayout或LineareLayout。我們需要這個子視圖來包裝其他子視圖,我們希望在屏幕中間添加其他子視圖,現在我們想要查看的任何東西,只需將該視圖添加爲此佈局的子項,如EditText或任何您喜歡的。

現在,當鍵盤顯示出來,中間滾動視圖將上攻滾動,不會扭曲你的UI ..

我希望這將是有益的,回來給我,如果你仍然有問題這.. ..)

0

刪除此行android:windowSoftInputMode =「adjustResize」從清單文件中的標記到該活動。

0

因爲我爲我的主要活動使用TabActivity,然後對我的選項卡活動使用FragmentActivity,清單設置似乎沒有幫助。所以,我的解決辦法是這樣的:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
    setContentView(R.layout.activity_fragment); 
    // Setup fragment 
    if (savedInstanceState == null) { 
     getSupportFragmentManager().beginTransaction() 
       .add(R.id.container, new Fragment()) 
       .commit(); 
    } 
} 

顯式調用創建setSoftInputMode(SOFT_INPUT_ADJUST_RESIZE)。希望如果manifest.xml不起作用,可以幫助一些人。

相關問題