如何从对话框中删除操作栏



getActionBar().hide(); 将导致 getActionBar 为空。这也不起作用:

<style name="NoActionBar" parent="@android:style/Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style> 

这是我的代码:

  public static void popupWindow(final Context context,String title ,String desc,final CrudStateCallback back){
    final Dialog dialog = new Dialog(context, R.style.ShowPopup);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));
    dialog.setContentView(R.layout.sticky_layout);
    colourTitleBar(context, dialog);
    String sansproEL = "fonts/source_sans_pro_extraLight.ttf";
    String sansproL = "fonts/source_sans_pro_light.ttf";
    Typeface sansproL_TF = Typeface.createFromAsset(context.getAssets(), sansproL);
    Typeface sansproEL_TF = Typeface.createFromAsset(context.getAssets(), sansproEL);
    ((TextView)dialog.findViewById(R.id.popup_text)).setTypeface(sansproL_TF);
    ((TextView)dialog.findViewById(R.id.popup_text2)).setTypeface(sansproEL_TF);
    TextView text = (TextView) dialog.findViewById(R.id.popup_text);
    TextView text2 = (TextView) dialog.findViewById(R.id.popup_text2);
    RelativeLayout container = (RelativeLayout) dialog.findViewById(R.id.all_container);
    View.OnClickListener dismissList = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if(back!= null)
                back.onResponse("");
        }
    };
    text.setText(title);
    text2.setText(desc);
    container.setOnClickListener(dismissList);
    PSLocationCenter.getInstance().instabug.setDialog(dialog);
    dialog.show();
    Handler han = new Handler();
    han.postDelayed(new Runnable() {
        @Override
        public void run() {
            try{
                dialog.dismiss();
            }catch (Exception e){
                Log.i("","error in popup window");
            }
            if(back!= null)
                back.onResponse("");
        }
    }, 3000);
}
  public static void colourTitleBar(Context context, Dialog dialog) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        dialog.getWindow().setStatusBarColor(context.getResources().getColor(android.R.color.transparent));
    }
}

还有我的风格:

<style name="ShowPopup">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowAnimationStyle">@style/ShowPopupAnimation</item>
    <item name="android:windowCloseOnTouchOutside">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowTitleSize">0dp</item>

使用 Theme.Holo.Light.NoActionBar 作为主题的父级怎么样?

您是否尝试简单地删除此行?

colourTitleBar(context, dialog);

您是否正在尝试删除操作栏或对话框的标题栏?如果是第一个,你可以尝试在活动上调用requestWindowFeature(),而不是对话框。在 setContentView() 之前,如前所述。

相关内容

  • 没有找到相关文章

最新更新