首页 > 移动平台 > 详细

Android 代码写控件

时间:2014-02-10 23:45:06      阅读:541      评论:0      收藏:0      [点我收藏+]

1.设置dialog弹出anthor

bubuko.com,布布扣
  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;
    }
bubuko.com,布布扣

 

 

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

bubuko.com,布布扣
 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);
bubuko.com,布布扣

 

3.代码设置android 4.0 roboto字体

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

Android 代码写控件

原文:http://www.cnblogs.com/lchd/p/3543361.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!