Reputation: 93
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>
well nothing works. note activity is fullScreen and tried with scrollview too, and cannot change the design. and EditText is the fragment. full screen fragment also not working. Hiding views doesnot work in Lollypop but works in kitkat.
Upvotes: 1
Views: 954
Reputation: 303
adjustPan not working with WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
try this:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
or this:
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);
}
Upvotes: 1
Reputation: 932
Try adding this android:windowSoftInputMode="stateHidden|adjustPan"
to the manifest file inside the activity tags of the "Activity" you're having an issue with.
For instance:
<activity
android:name=".ContactActivity"
android:label="@string/title_activity_contact"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan" >
</activity>
Upvotes: 0
Reputation: 6277
add this line in your activity manifest.
<activity android:windowSoftInputMode="adjustResize"> </activity>
or add
<activity android:windowSoftInputMode="adjustPan"> </activity>
as Rohit Arya suggests
NOTE :
After doing a lot of searching i found this. If you use the fullscreen tag (to remove the status bar from the activity) you can't use "adjustResize" without wrapping the activity in a ScrollView.
try this
EXAMPLE
<?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>
Upvotes: 0