私はグーグルで検索していましたが、2日間スタックオーバーフローが発生しましたが、助けになるものは見つかりませんでした。> => APIのソフトキーボードのDialogFragmentサイズが変更されていません24
私はスマートフォンでフルスクリーンのDialogFragmentとタブレットでモーダルダイアログを実装しようとしています。
これは、それが(APIレベル23デバイスで撮影)見えるようになっている方法です。
これは、それがAPIレベル24デバイス上でどのように見えるかです:
これは、APIレベルが< = 23のデバイスで、次のコードで動作します私はそれを複数の実デバイスとエミュレートされたデバイスでテストしました。
TestDialogFragment.java:
public class TestDialogFragment extends DialogFragment
{
private boolean isTablet;
public TestDialogFragment()
{
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
isTablet = getResources().getBoolean(R.bool.isTablet); // defaults to false, true >= sw600dp
if (isTablet)
{
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth);
} else
{
setStyle(STYLE_NO_FRAME, android.R.style.Theme_Holo_Light);
}
setCancelable(false);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
savedInstanceState)
{
if (!isTablet)
{
Window window = getDialog().getWindow();
if (window != null)
{
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
}
return inflater.inflate(R.layout.dialog_fragment, container, false);
}
@Override
public void onStart()
{
super.onStart();
if (isTablet)
{
Dialog d = getDialog();
if (d != null)
{
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
d.getWindow().setLayout(width, height);
}
}
}
}
dialog_fragment.xml:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/dialog_toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:maxLines="2"
android:paddingBottom="14dp"
android:paddingTop="14dp"
android:text="@string/dialog_title"
android:textSize="20sp" />
</android.support.v7.widget.Toolbar>
<EditText
android:id="@+id/edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:ems="10"
android:hint="@string/edit_text_1"
android:inputType="text"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/progress_bar"
app:layout_constraintTop_toBottomOf="@+id/dialog_toolbar"
app:theme="@style/AppTheme" />
<ProgressBar
android:id="@+id/progress_bar"
style="?android:progressBarStyle"
android:layout_width="24dp"
android:layout_height="0dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/edit_text"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toRightOf="@id/edit_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/edit_text"
app:layout_constraintWidth_default="wrap"
tools:visibility="visible" />
<android.support.v7.widget.RecyclerView
android:id="@+id/results_recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_text"/>
<TextView
android:id="@+id/no_results_text_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="32dp"
android:gravity="center"
android:text="@string/no_results"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/edit_text"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintHeight_default="wrap"
tools:visibility="visible" />
</android.support.constraint.ConstraintLayout>
私はこれもAPIレベル24とアップで動作しない理由を把握することはできません。 Android 24のリリースノートでこの動作に変更はありません。
私のコードに何か問題はありますか、何か見落としましたか?
ご協力いただきありがとうございます。