2015-10-30 5 views
6

少し混乱します。ステータスバーによるダイアログフラグオーバーラップ

最初に、ツールバーを作成してステータスバーでオーバーラップすると、親XMLにfitSysmtemWindow="true"を追加するだけで問題なく動作します。

しかし、フルスクリーンDialogFragmentを作成すると、ステータスバーでも重なってしまいます。 fitSystemWindow="true"を追加しようとしましたが動作しません。

android 5.0+にのみ存在します。ステータスバーを半透明に設定していませんでした。

ここに私の悪い工学のための私のDialogFragmentコード

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
        Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    View view = inflater.inflate(R.layout.fragment_create_bill_dialog,container, false); 

    return view; 
} 

@NonNull 
@Override 
public Dialog onCreateDialog(Bundle savedInstanceState) { 
    Dialog dialog = super.onCreateDialog(savedInstanceState); 
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    return dialog; 
} 

Thanks.Sorry。

答えて

0

これが役立つことがあります。

View decorView = getWindow().getDecorView(); 

//ステータスバーを非表示にします。

int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 

decorView.setSystemUiVisibility(uiOptions); 

// //ステータスバーが隠されているので、あまりにも必要に応じていることを隠す場合は、アクションバーを表示してはならないことに注意してください。

ActionBar actionBar = getActionBar(); 

actionBar.hide(); 

デバイス4.1以降

+2

とにかくこの問題をステータスバーを隠すことなく修正していただきありがとうございます。 –

2

私は同じ問題を抱えていたため、上記のコードのdiablesのステータスバー。 Dialog Fragmentのルートビューの上部に25dpのパディングを追加して、ステータスバーと重ならないようにして解決しました。

public void onViewCreated(View view, Bundle savedInstanceState) { 
    super.onViewCreated(view, savedInstanceState); 

    //If showing as a dialog, add some padding at the top to ensure it doesn't overlap status bar 
    if (getDialog() != null) { 
     getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 
     view.setPadding(0, (int)PresentationUtils.convertDpToPixel(25f, getContext()), 0, 0); 
     view.requestLayout(); 
    } 
... 
} 

ところで、私はPXにDPを変換するために使用していutilの方法は、あなたのスタイルでは、ここでConverting pixels to dp

1

見つけることができます:

<style name="MyDialog" parent="@android:style/Theme.NoTitleBar.Fullscreen"></style> 

あなたのダイアログの場合:

new Dialog(builder.context, R.style.MyDialog); 
関連する問題