Example usage for android.util TypedValue COMPLEX_UNIT_DIP

List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP

Introduction

In this page you can find the example usage for android.util TypedValue COMPLEX_UNIT_DIP.

Prototype

int COMPLEX_UNIT_DIP

To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.

Click Source Link

Document

#TYPE_DIMENSION complex unit: Value is Device Independent Pixels.

Usage

From source file:mp.paschalis.App.java

public static void setStyleSuccessDirection(TextView pTextView) {
    setStyleSuccessDirectionColor(pTextView);
    pTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);

}

From source file:mp.paschalis.App.java

public static void setStyleDirection(TextView pTextView) {
    pTextView.setTextColor(Color.WHITE);
    pTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);

}

From source file:com.camnter.easyrecyclerviewsidebar.EasyRecyclerViewSidebar.java

private float dp2px(int dp) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, this.metrics);
}

From source file:com.camnter.easyrecyclerviewsidebar.EasyRecyclerViewSidebar.java

private float dp2px(float dp) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, this.metrics);
}

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

private void addRedDotTab(final int position, String title, int resId) {
    LinearLayout tabLayout = new LinearLayout(getContext());
    tabLayout.setOrientation(LinearLayout.HORIZONTAL);
    tabLayout.setGravity(Gravity.CENTER);
    TextView tab = new TextView(getContext());
    tab.setText(title);//www . ja v  a 2 s .  co m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);

    tab.setSingleLine();
    tab.setTextColor(getResources().getColorStateList(R.color.pst_tab_text_selector));
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f);
    tabLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });

    tabLayout.addView(tab, 0);
    ImageView tabImg = new ImageView(getContext());
    LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    tabImgParams.setMargins(DeviceUtils.dip2px(getContext(), 5), DeviceUtils.dip2px(getContext(), 10), 0, 0);
    tabImgParams.gravity = Gravity.TOP;
    tabImg.setLayoutParams(tabImgParams);

    tabLayout.addView(tabImg, 1);
    tabsContainer.addView(tabLayout);
}

From source file:com.google.android.libraries.cast.companionlibrary.utils.Utils.java

/**
 * Converts DIP (or DP) to Pixels/*from   w  ww  .j  av a 2  s. co m*/
 */
public static int convertDpToPixel(Context context, float dp) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());
}

From source file:cn.scujcc.bug.bitcoinplatformandroid.fragment.OrderFragment.java

@Nullable
@Override//from   w  w w  .  ja  v  a  2s .  com
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragmnet_quotationinformation, container, false);

    mRecyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);

    mNoneText = (TextView) view.findViewById(R.id.none_text);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    mSwipeRefreshWidget = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_widget);

    mSwipeRefreshWidget.setOnRefreshListener(this);

    mSwipeRefreshWidget.setColorSchemeResources(R.color.colorPrimary, R.color.colorPrimaryDark);

    mSwipeRefreshWidget.setProgressViewOffset(false, 0, (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()));

    setTitle(view, "?");

    return view;
}

From source file:cn.scujcc.bug.bitcoinplatformandroid.fragment.QuotationInformationFragment.java

@Nullable
@Override/*from w w w  .  j av  a 2 s.co  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragmnet_quotationinformation, container, false);

    setHasOptionsMenu(true);
    setTitle(view, "");

    mNoneText = (TextView) view.findViewById(R.id.none_text);

    mSwipeRefreshWidget = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_widget);

    mSwipeRefreshWidget.setOnRefreshListener(this);

    mSwipeRefreshWidget.setColorSchemeResources(R.color.colorPrimary, R.color.colorPrimaryDark);

    mSwipeRefreshWidget.setProgressViewOffset(false, 0, (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()));

    mRecyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);

    //???,?
    mRecyclerView.setHasFixedSize(true);

    // 
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    //Adapter
    mAdapter = new CardAdapter();
    mRecyclerView.setAdapter(mAdapter);

    //??
    NewsAsyncTask task = new NewsAsyncTask();
    task.execute();

    mSwipeRefreshWidget.setRefreshing(true);

    return view;
}

From source file:com.skytree.epubtest.BookViewActivity.java

public int getPSFromDP(float dps) {
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dps, metrics);
    return (int) pixels;
}

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

private void addWarningTab(final int position, String title, int resId) {
    LinearLayout tabLayout = new LinearLayout(getContext());
    tabLayout.setOrientation(LinearLayout.HORIZONTAL);
    tabLayout.setGravity(Gravity.CENTER);

    ImageView tabImg = new ImageView(getContext());
    int width = DimenUtils.dp2px(getContext(), 18);
    LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(width, width);
    tabImgParams.setMargins(0, 0, DimenUtils.dp2px(getContext(), 10), 0);
    tabImgParams.gravity = Gravity.CENTER;
    tabImg.setLayoutParams(tabImgParams);
    if (resId != -1) {
        tabImg.setBackgroundResource(resId);
        tabImg.setVisibility(View.VISIBLE);
    } else {/*from  ww w  .jav a 2  s  .c  o  m*/
        tabImg.setVisibility(View.GONE);
    }
    tabLayout.addView(tabImg, 0);

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(getResources().getColorStateList(
            mTextChangeable ? R.color.pst_tab_changeable_text_selector : R.color.pst_tab_text_selector));
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f);
    tabLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });
    tabLayout.addView(tab, 1);

    tabsContainer.addView(tabLayout);
}