QDa

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1.设置dialog弹出anthor

  public static SearchDialog getSearchDialog(Context context,OnDismissListener listener, View anchor){
        SearchDialog dialog = new SearchDialog(context, R.style.popdialog); // 创建Dialog并设置样式主题
        Window win = dialog.getWindow();
        WindowManager.LayoutParams params = new WindowManager.LayoutParams();

        int positionX = 0;
        int positionY = anchor.getHeight() -
                context.getResources().getDimensionPixelSize(R.dimen.search_dialog_top_margin);
        params.x = positionX;
        params.y = positionY;
        win.setAttributes(params);
        win.setGravity(Gravity.TOP);
        win.setWindowAnimations(R.style.AnimationPreview);
        dialog.setCanceledOnTouchOutside(true); //设置点击Dialog外部任意区域关闭Dialog
        dialog.setOnDismissListener(listener);
        return dialog;
    }

 

 

2.Dialog内部设置Dialog相对位置

 android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = android.view.WindowManager.LayoutParams.WRAP_CONTENT; 
        params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

 

3.代码设置android 4.0 roboto字体

 mTextView.setTextAppearance(context, resid);
<style name="RobotoFontAppearence">
        <item name="android:fontFamily">sans-serif-light</item>
</style>

 

posted on 2014-02-10 18:19  QDa  阅读(422)  评论(0编辑  收藏  举报