Ich möchte in der Lage sein, die Größe des actionMode oder mindestens einen actionMode mit der gleichen Größe der Symbolleiste.ActionMode kleiner als die Symbolleiste in Querformat
Ich habe eine Symbolleiste mit fester Größe im Hoch- und Querformat. Ich benutze 56dp (Wert für die mobile Porträt-Symbolleiste) als Wert für beide.
Meine Symbolleiste ist in Ordnung. Das Problem ist, dass mein actionMode während der Orientierungsänderung den Standardwert von android? Attr/actionBarSize erhält. In der Landschaft habe ich also einen actionMode, der kleiner ist als die Symbolleiste.
Normaler ActionMode Code
if (actionMode == null) {
actionMode = ((AppCompatActivity)getActivity()).startSupportActionMode(actionModeCallback);
}
ich in onConfigurationChanged versucht, die Größe des actionMode zu ändern, aber ohne Glück. Dies ist ein Beispiel, um die Größe der Symbolleiste zu ändern. Anscheinend gibt es keine Möglichkeit, dasselbe für den actionMode zu tun. Irgendwelche Vorschläge? Danke
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Toolbar toolbar = ((MainActivity)getActivity()).getToolbar(); //my custom method to get the toolbar
if (toolbar != null) {
int toolbarHeight = (int)getResources().getDimension(R.dimen.toolbar_height);
toolbar.setMinimumHeight(toolbarHeight);
ViewGroup.LayoutParams lp = toolbar.getLayoutParams();
lp.height = toolbarHeight;
toolbar.setLayoutParams(lp);
}
}
}