我想滾動我的佈局softinput鍵盤可見時。我已經在我的xml在適當的地方定義滾動視圖,但當鍵盤可見時,它隱藏了一些佈局的一部分鈕釦。 我已閱讀stackoveflow Link scrollview不工作時,活動是FULL_SCREEN.If它是真的,那麼我怎麼可以滾動我的佈局時softinput可見。如何滾動佈局當鍵盤可見在活動與FULL_SCREEN
4
A
回答
1
使用此自定義相對佈局在烏爾XML檢測softkeyboard與
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
/**
* RelativeLayout that can detect when the soft keyboard is shown and hidden.
*
*/
public class RelativeLayoutThatDetectsSoftKeyboard extends RelativeLayout {
public RelativeLayoutThatDetectsSoftKeyboard(Context context, AttributeSet attrs) {
super(context, attrs);
}
public interface Listener {
public void onSoftKeyboardShown(boolean isShowing);
}
private Listener listener;
public void setListener(Listener listener) {
this.listener = listener;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = MeasureSpec.getSize(heightMeasureSpec);
Activity activity = (Activity)getContext();
Rect rect = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
int statusBarHeight = rect.top;
int screenHeight = activity.getWindowManager().getDefaultDisplay().getHeight();
int diff = (screenHeight - statusBarHeight) - height;
if (listener != null) {
listener.onSoftKeyboardShown(diff>128); // assume all soft keyboards are at least 128 pixels high
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
然後基於鍵盤
RelativeLayoutThatDetectsSoftKeyboard mainLayout = (RelativeLayoutThatDetectsSoftKeyboard)V.findViewById(R.id.dealerSearchView);
mainLayout.setListener(this);
@Override
public void onSoftKeyboardShown(boolean isShowing) {
if(isShowing) {
} else {
}
}
實現RelativeLayoutThatDetectsSoftKeyboard.Listener您活性研究班能見度將佈局上下移動使用佈局參數
0
你必須改變你的清單文件
在您的活動標籤
機器人:windowSoftInputMode = 「adjustPan」 添加此。
看到這個http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
+0
我已經定義android:windowSoftInputMode =「stateVisible | adjustResize | adjustPan」但它仍然不工作 –
相關問題
- 1. 當鍵盤可見時滾動內容
- 2. android可滾動的活動佈局
- 3. 如何在鍵盤上顯示我的滾動佈局?
- 4. 在網格佈局當鍵盤在xamarin.forms中打開時如何滾動頁面?
- 5. 移動起來防止線性佈局時,軟鍵盤可見
- 6. 當鍵盤向上時佈局不滾動
- 7. 當鍵盤出現時平滑滾動佈局?
- 8. 當鍵盤可見時,Windows Phone 8滾動
- 9. 當鍵盤可見時Xamarin Forms視圖不滾動
- 10. 當鍵盤可見時需要滾動頁面
- 11. Android的滾動型不活動與抽屜佈局滾動
- 12. 如何擁有不可見的可滾動佈局
- 13. Android的佈局不滾動起來的時候軟鍵可見
- 14. 如何確定活動鍵盤佈局的名稱?
- 15. 如何在全屏活動的鍵盤焦點上移動佈局
- 16. 如何在保留滾動活動的同時顯示鍵盤?
- 17. 每當佈局變得可見時都會出現軟鍵盤
- 18. 活動與數字鍵盤
- 19. 如何使2 TextViews可滾動而不使佈局可滾動?
- 20. 如何使線性佈局可滾動?
- 21. 如何創建可滾動佈局
- 22. 佈局在鍵盤出現時向上滾動
- 23. 鍵盤彈出來滾動在Android中的完整佈局
- 24. Android可滾動佈局與recyclerview
- 25. 可滾動的相對佈局與ImageViews
- 26. Android佈局 - 製作可滾動佈局
- 27. 使鍵盤在啓動時可見
- 28. 本機鍵盤在手機上可見時禁用滾動
- 29. iOS:scrollView在鍵盤可見時不滾動到正確位置
- 30. 使鍵盤活動時可以滾動視圖
告訴我們你的代碼PLZ –
<滾動型機器人:ID = 「@ + ID/scrol」 機器人:layout_width = 「FILL_PARENT」 機器人:layout_height = 「FILL_PARENT」> <的EditText機器人:ID = 「@ + ID /測試」 機器人:layout_width = 「FILL_PARENT」 機器人:layout_height = 「WRAP_CONTENT」 /> <的EditText機器人:ID =「@ + id/test1「 android:layout_width =」fill_parent「 android:layout_height =」wrap_content「 android:layout_below =」@ id/test「 /> RelativeLayout> –
可能會有助於http://stackoverflow.com/questions/11298479/can-not-get-scrollview-to-scroll-when-soft-keyboard-is-shown使您的滾動視圖父母 –