I try to set the adjustment of my fragments differently when the keyboard opens, but for the moment I have no positive results.enter code here
The objective would be to readjust only one of the two fragments.
Here is an example
Activity
public class MainActivity extends Activity {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.frame1, new PlaceholderFragment())
.commit();
getFragmentManager().beginTransaction()
.add(R.id.frame2, new PlaceholderFragment1())
.commit();
}
}
...
fragments:
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.noresize);
// LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
return inflater.inflate(R.layout.fragment_main, container, false);
}
}
public static class PlaceholderFragment1 extends Fragment {
public PlaceholderFragment1() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
View rootView = inflater.inflate(R.layout.fragment_main_2, container, false);
return rootView;
}
}
main layout of the Activity:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame"
android:orientation="horizontal"
>
<FrameLayout
android:id="@+id/frame1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/frame2"
android:background="#30000000"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
</LinearLayout>
ok saw that I redefined twice SoftInputMode on the activity, this is unlikely to succeed. so, is it possible to do something like that fragment.getWindows.setSoftInputMode (...
sorry for my english ...