Android Dip to Pixel Convert dip2pixel(Context context, float n)

Here you can find the source of dip2pixel(Context context, float n)

Description

dippixel

License

Apache License

Declaration

public static int dip2pixel(Context context, float n) 

Method Source Code

//package com.java2s;
/*//from   w  w  w  .j  av a  2s . co m
 * Copyright 2011 - AndroidQuery.com (tinyeeliu@gmail.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

import android.content.Context;

import android.util.TypedValue;

public class Main {
    public static int dip2pixel(Context context, float n) {
        int value = (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, n, context.getResources()
                        .getDisplayMetrics());
        return value;
    }
}

Related

  1. convertToPixel(Context context, float dp)
  2. getPixelFromDp(float dp, Context context)
  3. convertDptoPx(Context context, int dp)
  4. dip2px(Context context, int dip)
  5. dipValue(Context context, int dip)
  6. dip2px(Context context, float dipValue)
  7. dip2px(Context context, float dipValue)
  8. dip2px(Context context, float dpValue)
  9. dip2px(Context context, float dpValue)