ダイアログフラグメントを使用してフルスクリーンダイアログを設定する方法

Zohaib Siddique

ダイアログフラグメントを使用してフルスクリーンダイアログを作成しています。ダイアログは正常に表示されますが、問題はその幅と高さにあります。フルスクリーンサイズを表示することはできません。アクティビティのように全画面サイズを累積して幅と高さを設定したい。ダイアログの幅と高さを設定して全画面サイズに累積する方法を教えてください。

CustomeDialogFramgnet:

public class CustomDialogFragment extends DialogFragment {
    /** The system calls this to get the DialogFragment's layout, regardless
     of whether it's being displayed as a dialog or an embedded fragment. */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout to use as dialog or embedded fragment
        View rootView = inflater.inflate(R.layout.item_fragment, null, false);

        Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
        toolbar.setTitle("Dialog title");

        ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setHomeAsUpIndicator(android.R.drawable.ic_menu_close_clear_cancel);
        }

        return rootView;
    }

    /** The system calls this only when creating the layout in a dialog. */
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // The only reason you might override this method when using onCreateView() is
        // to modify any dialog characteristics. For example, the dialog includes a
        // title by default, but your custom layout might not need it. So here you can
        // remove the dialog title, but you must call the superclass to get the Dialog.
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        return dialog;
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        menu.clear();
        getActivity().getMenuInflater().inflate(R.menu.alert_dialog_input, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_save) {
            // handle confirmation button click here
            return true;
        } else if (id == android.R.id.home) {
            // handle close button click here
            dismiss();
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

item_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/listView"
            android:text="zohaib">
        </TextView>

    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>
ひまんしゅ1496

以下のように、から拡張themeするstyle.xml作成しますTheme.AppCompat.Light.DarkActionBar

<style name="DialogFragmentTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="android:paddingRight">0dp</item>
    <item name="android:paddingLeft">0dp</item>
    <item name="android:layout_width">match_parent</item>
    <item name="android:windowNoTitle">true</item>
</style>

styleを開いているときに作成したdialogものを次のように設定します。

CustomDialogFragment mDialog = new CustomDialogFragment();
...
mDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogFragmentTheme);
mDialog.show(getSupportFragmentManager(), "DialogFragment");

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

ダイアログフローでオブジェクトのリストをプラメーターとしてコンテキストを設定する

分類Dev

mapActivityからダイアログフラグメントにデータを設定する方法

分類Dev

カスタムアラートダイアログをフルスクリーンにする方法

分類Dev

Springアプリケーションのログファイル名を設定してtomcat / logsフォルダにログを記録する方法は?

分類Dev

フラグメントを使用したダイアログボックスにエラーが表示される

分類Dev

リダイレクトを使用してWildflyロードバランシングを設定する方法

分類Dev

下部シートのダイアログフラグメントにテキストボタンを設定する方法

分類Dev

IntelliJIdeaデザイナーが作成したダイアログを使用してクラスのフィールドでアクションを実行する方法

分類Dev

フラグメントからアプリダイアログを終了する

分類Dev

フラグメントでマテリアルダイアログを使用する

分類Dev

アラートダイアログのコンテンツとしてxmlレイアウトファイル全体を設定します

分類Dev

reactを使用してモーダルダイアログをフルスクリーンモードにする方法は?

分類Dev

OSMとリーフレットを使用してカスタムフロアタイルにアイコンをレンダリングする

分類Dev

FlutterでNavigator.pushNamedを使用してフルスクリーンダイアログを開く方法は?

分類Dev

CSS3トランジションフリップエフェクトを使用してモーダルダイアログを表示しますか?

分類Dev

CSS3トランジションフリップエフェクトを使用してモーダルダイアログを表示しますか?

分類Dev

ダイアログ(拡張ライブラリダイアログ)で検証後にフィールドフォーカスを設定します

分類Dev

C ++を使用してLUAでダイアログとメニューを持つインタラクティブNPCをスクリプト化する方法は?

分類Dev

Androidフラグメントに簡単なOK情報ダイアログボックスを追加する方法

分類Dev

アラートダイアログのタイトルを設定する方法

分類Dev

ファイルまたはフォルダーをドラッグアンドドロップしてPowerShellスクリプトを実行する

分類Dev

ボットフレームワークv4でウェルカムメッセージとしてダイアログを設定する方法

分類Dev

ダイアログボタンのテキストのフォントサイズを設定する方法

分類Dev

スクリプトを使用してcq5ダイアログのテキストフィールドのグループを無効にする方法

分類Dev

クリーンセッションフラグをfalseに設定してクライアントがMQTTブローカーに接続する方法

分類Dev

ocクライアントを使用してオープンシフトでログをテールする方法

分類Dev

コンポーネントダイアログでタグをフィルタリングする方法。Adobe CQ

分類Dev

プラグイン開発: FileDialog を使用して新しいファイル ダイアログを作成する

分類Dev

ダイアログをフラグメントで表示する方法| アンドロイド

Related 関連記事

  1. 1

    ダイアログフローでオブジェクトのリストをプラメーターとしてコンテキストを設定する

  2. 2

    mapActivityからダイアログフラグメントにデータを設定する方法

  3. 3

    カスタムアラートダイアログをフルスクリーンにする方法

  4. 4

    Springアプリケーションのログファイル名を設定してtomcat / logsフォルダにログを記録する方法は?

  5. 5

    フラグメントを使用したダイアログボックスにエラーが表示される

  6. 6

    リダイレクトを使用してWildflyロードバランシングを設定する方法

  7. 7

    下部シートのダイアログフラグメントにテキストボタンを設定する方法

  8. 8

    IntelliJIdeaデザイナーが作成したダイアログを使用してクラスのフィールドでアクションを実行する方法

  9. 9

    フラグメントからアプリダイアログを終了する

  10. 10

    フラグメントでマテリアルダイアログを使用する

  11. 11

    アラートダイアログのコンテンツとしてxmlレイアウトファイル全体を設定します

  12. 12

    reactを使用してモーダルダイアログをフルスクリーンモードにする方法は?

  13. 13

    OSMとリーフレットを使用してカスタムフロアタイルにアイコンをレンダリングする

  14. 14

    FlutterでNavigator.pushNamedを使用してフルスクリーンダイアログを開く方法は?

  15. 15

    CSS3トランジションフリップエフェクトを使用してモーダルダイアログを表示しますか?

  16. 16

    CSS3トランジションフリップエフェクトを使用してモーダルダイアログを表示しますか?

  17. 17

    ダイアログ(拡張ライブラリダイアログ)で検証後にフィールドフォーカスを設定します

  18. 18

    C ++を使用してLUAでダイアログとメニューを持つインタラクティブNPCをスクリプト化する方法は?

  19. 19

    Androidフラグメントに簡単なOK情報ダイアログボックスを追加する方法

  20. 20

    アラートダイアログのタイトルを設定する方法

  21. 21

    ファイルまたはフォルダーをドラッグアンドドロップしてPowerShellスクリプトを実行する

  22. 22

    ボットフレームワークv4でウェルカムメッセージとしてダイアログを設定する方法

  23. 23

    ダイアログボタンのテキストのフォントサイズを設定する方法

  24. 24

    スクリプトを使用してcq5ダイアログのテキストフィールドのグループを無効にする方法

  25. 25

    クリーンセッションフラグをfalseに設定してクライアントがMQTTブローカーに接続する方法

  26. 26

    ocクライアントを使用してオープンシフトでログをテールする方法

  27. 27

    コンポーネントダイアログでタグをフィルタリングする方法。Adobe CQ

  28. 28

    プラグイン開発: FileDialog を使用して新しいファイル ダイアログを作成する

  29. 29

    ダイアログをフラグメントで表示する方法| アンドロイド

ホットタグ

アーカイブ