getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
@Override
public void onResume() {
super.onResume();
mView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
mView.getWindowVisibleDisplayFrame(r);
int heightDiff = mView.getRootView().getHeight() - (r.bottom - r.top);
if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
//ok now we know the keyboard is up...
mView.findViewById(R.id.txt_error_message).setVisibility(View.GONE);
mView.findViewById(R.id.btn_user_signup).setVisibility(View.GONE);
} else {
//ok now we know the keyboard is down...
mView.findViewById(R.id.txt_error_message).setVisibility(View.VISIBLE);
mView.findViewById(R.id.btn_user_signup).setVisibility(View.VISIBLE);
}
}
});
}
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frag_cont_registration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical"
tools:context="com.apps.robo.fragments.FragmentItcRegistration">
<EditText
android:id="@+id/input_phone_email"
android:layout_width="218dp"
android:layout_height="45dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="36dp"
android:background="@drawable/edit_text_border_bottom"
android:fontFamily="@string/light_roboto"
android:gravity="bottom|center"
android:hint="@string/hint_enter_phone_number"
android:inputType="number"
android:maxLines="1"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:textSize="14sp"
android:cursorVisible="true"/>
<!-- android:singleLine="true" -->
<TextView
android:id="@+id/txt_error_message"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_gravity="center"
android:fontFamily="@string/light_roboto"
android:gravity="center"
android:text="@string/enter_email"
android:textColor="@android:color/white"
android:textSize="15sp"
android:visibility="gone" />
<Button
android:id="@+id/btn_user_signup"
android:layout_width="218dp"
android:layout_height="38dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="24sp"
android:background="@drawable/bg_buttton_white_border"
android:fontFamily="@string/medium_roboto"
android:gravity="center"
android:text="@string/btn_label_submit"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout>
没有任何作品。注意活动是全屏和 尝试使用scrollview,也无法改变设计。和EditText是片段。全屏片段也无法正常工作。隐藏的视图在Lollypop中不起作用,但在kitkat中起作用。
答案 0 :(得分:1)
试试这个:
android:windowSoftInputMode="adjustPan" >
答案 1 :(得分:1)
adjustPan无法使用WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
试试这个:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
或者这个:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
w.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
答案 2 :(得分:0)
在活动清单中添加此行。
<activity android:windowSoftInputMode="adjustResize"> </activity>
或添加
<activity android:windowSoftInputMode="adjustPan"> </activity>
注意:
经过大量搜索,我发现了这一点。如果您使用全屏标记(从活动中删除状态栏),则不能使用“adjustResize”而不将活动包装在ScrollView中。
试试这个
示例强>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
...
...
</ScrollView>
答案 3 :(得分:0)
尝试将此android:windowSoftInputMode="stateHidden|adjustPan"
添加到&#34;活动&#34;的活动标记内的清单文件中。你遇到了问题。
例如:
<activity
android:name=".ContactActivity"
android:label="@string/title_activity_contact"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan" >
</activity>