我的位置: 首页 >> App >> App知识

Android “四分之一”屏实现

118        RelativeLayout.LayoutParams lp = (LayoutParams) mContentViewParent.getLayoutParams();

119        lp.leftMargin = 0;

120        lp.rightMargin = 0;

121        mContentViewParent.setLayoutParams(lp);

122        isOpen = true;

123    }

124     

125    /**

126     * 根据手机的分辨率从 dp 的单位 转成为 px(像素)

127     */

128    public static int dip2px(Context context, float dpValue) {  

129        final float scale = context.getResources().getDisplayMetrics().density;  

130        return (int) (dpValue * scale + 0.5f);  

131    }  

132   

133    /**

134     * 根据手机的分辨率从 px(像素) 的单位 转成为 dp

135     */

136    public static int px2dip(Context context, float pxValue) {  

137        final float scale = context.getResources().getDisplayMetrics().density;  

138        return (int) (pxValue / scale + 0.5f);  

139    }

140}


翻页: 1 2 3 4 5 6 7

App知识

客户中心

版权2005-2020    聚卓网络有限公司    电话:18589057325    QQ:2338754269   粤ICP备14021702号

地址:深圳市宝安区 37区龙井一路100号 新乐社区工作站办公大楼侧门6楼(近翻身路、新乐社区健康服务中心)

技术支持: 网站建设