Example usage for android.util TypedValue COMPLEX_UNIT_PX

List of usage examples for android.util TypedValue COMPLEX_UNIT_PX

Introduction

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

Prototype

int COMPLEX_UNIT_PX

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

Click Source Link

Document

#TYPE_DIMENSION complex unit: Value is raw pixels.

Usage

From source file:com.meishai.ui.sliding.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                tab.setText(tab.getText().toString().toUpperCase(locale));
            }//from  w w w  . j  av  a 2s  . co m
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.learn.mobile.customview.henrytao.SmoothCollapsingToolbarLayout.java

protected void updateViews(float ratio) {
    int startOffsetX = 0;
    int startOffsetY = getAppBarLayout().getMeasuredHeight() - getMeasuredHeight();
    ViewCompat.setTranslationX(this,
            startOffsetX + getTranslationOffset(mExpandedOffsetX, mCollapsedOffsetX, ratio));
    ViewCompat.setTranslationY(this,
            startOffsetY - getTranslationOffset(mExpandedOffsetY, mCollapsedOffsetY, ratio));
    if (isAvatarSizeEnabled()) {
        ViewGroup.LayoutParams params = vAvatar.getLayoutParams();
        params.height = params.width = (int) getTranslationOffset(mExpandedAvatarSize, mCollapsedAvatarSize,
                ratio);/*  www . ja  v  a 2 s  . c  om*/
    }
    if (isTitleTextSizeEnabled()) {
        vTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getTranslationOffset(mExpandedTitleTextSize, mCollapsedTitleTextSize, ratio));
    }
    if (isSubtitleTextSizeEnabled()) {
        vSubtitle.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getTranslationOffset(mExpandedSubtitleTextSize, mCollapsedSubTitleTextSize, ratio));
    }
    if (mOnOffsetChangedListener != null) {
        mOnOffsetChangedListener.onOffsetChanged(ratio);
    }
    log("test updateViews | %d | %f",
            (int) (mExpandedAvatarSize + ratio * (mCollapsedAvatarSize - mExpandedAvatarSize)), ratio);
}

From source file:com.chao.facebookzc.widget.LoginButton.java

/**
 * Create the LoginButton by inflating from XML
 *
 * @see android.view.View#View(android.content.Context, android.util.AttributeSet)
 *//*w w  w  .  ja  v  a2  s.c o  m*/
public LoginButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        this.setGravity(Gravity.CENTER);
        this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setTypeface(Typeface.DEFAULT_BOLD);
        if (isInEditMode()) {
            // cannot use a drawable in edit mode, so setting the background color instead
            // of a background resource.
            this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
            // hardcoding in edit mode as getResources().getString() doesn't seem to work in IntelliJ
            loginText = "Log in with Facebook";
        } else {
            this.setBackgroundResource(R.drawable.com_facebook_button_blue);
            this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.com_facebook_inverse_icon, 0, 0, 0);
            this.setCompoundDrawablePadding(getResources()
                    .getDimensionPixelSize(R.dimen.com_facebook_loginview_compound_drawable_padding));
            this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom));
        }
    }
    parseAttributes(attrs);
    if (!isInEditMode()) {
        initializeActiveSessionWithCachedToken(context);
    }
}

From source file:com.phonegap.plugins.slaveBrowser.SlaveBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url       The url to load./*from  w w  w  .ja v  a  2 s. com*/
 * @param jsonObject 
 */
public String showWebPage(final String url, JSONObject options, String myNewTitle) {
    // Determine if we should hide the location bar.
    if (options != null) {
        showLocationBar = options.optBoolean("showLocationBar", true);
    }
    zeTitle = myNewTitle;

    // Create dialog in new thread 
    Runnable runnable = new Runnable() {
        public void run() {
            dialog = new Dialog(ctx.getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    try {
                        JSONObject obj = new JSONObject();
                        obj.put("type", CLOSE_EVENT);
                        sendUpdate(obj, false);
                    } catch (JSONException e) {
                        Log.d(LOG_TAG, "Should never happen");
                    }
                }
            });

            LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            LinearLayout.LayoutParams forwardParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT, 1.0f);
            LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            LinearLayout.LayoutParams wvParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT);
            LinearLayout main = new LinearLayout(ctx.getContext());
            main.setOrientation(LinearLayout.VERTICAL);

            LinearLayout toolbar = new LinearLayout(ctx.getContext());
            toolbar.setOrientation(LinearLayout.HORIZONTAL);

            edittext = new TextView(ctx.getContext());
            edittext.setId(3);
            edittext.setSingleLine(true);
            edittext.setText(zeTitle);
            edittext.setTextSize(TypedValue.COMPLEX_UNIT_PX, 24);
            edittext.setGravity(Gravity.CENTER);
            edittext.setTextColor(Color.DKGRAY);
            edittext.setTypeface(Typeface.DEFAULT_BOLD);
            edittext.setLayoutParams(editParams);

            webview = new WebView(ctx.getContext());
            webview.getSettings().setJavaScriptEnabled(true);
            webview.getSettings().setBuiltInZoomControls(true);

            // dda: intercept calls to console.log
            webview.setWebChromeClient(new WebChromeClient() {
                public boolean onConsoleMessage(ConsoleMessage cmsg) {
                    // check secret prefix
                    if (cmsg.message().startsWith("MAGICHTML")) {
                        String msg = cmsg.message().substring(9); // strip off prefix
                        /* process HTML */
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", PAGE_LOADED);
                            obj.put("html", msg);
                            sendUpdate(obj, true);
                        } catch (JSONException e) {
                            Log.d(LOG_TAG, "This should never happen");
                        }
                        return true;
                    }
                    return false;
                }
            });

            // dda: inject the JavaScript on page load
            webview.setWebViewClient(new SlaveBrowserClient(edittext) {
                public void onPageFinished(WebView view, String address) {
                    // have the page spill its guts, with a secret prefix
                    view.loadUrl(
                            "javascript:console.log('MAGICHTML'+document.getElementsByTagName('html')[0].innerHTML);");
                }
            });

            webview.loadUrl(url);
            webview.setId(5);
            webview.setInitialScale(0);
            webview.setLayoutParams(wvParams);
            webview.requestFocus();
            webview.requestFocusFromTouch();

            toolbar.addView(edittext);

            if (getShowLocationBar()) {
                main.addView(toolbar);
            }
            main.addView(webview);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.FILL_PARENT;
            lp.height = WindowManager.LayoutParams.FILL_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
        }

        private Bitmap loadDrawable(String filename) throws java.io.IOException {
            InputStream input = ctx.getAssets().open(filename);
            return BitmapFactory.decodeStream(input);
        }
    };
    this.ctx.runOnUiThread(runnable);
    return "";
}

From source file:com.scut.gof.coordinator.main.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from w  w  w.j a  v  a  2  s .  c om*/
            }
        }
    }

}

From source file:com.warmtel.news.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from  w  ww  . j  a va  2 s.c o m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                /**
                 * ?
                 * @author Diesel ?
                 */
                tab.setBackgroundResource(R.drawable.btn_common_normal);
            }
        }
    }

}

From source file:ar.com.xpasta.Controls.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            if (textAllCaps)
                tab.setAllCaps(true);//from   w w  w  .j  av a  2  s.  c om
        }
    }
}

From source file:com.zuzhili.ui.views.PagerSlidingTabStrip.java

private void updateTabStyles() {
    defaultTabLayoutParams = new LinearLayout.LayoutParams(widthPixels / tabCount, LayoutParams.FILL_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT, 1.0f);
    for (int i = 0; i < tabCount; i++) {

        TextView tab = (TextView) tabsContainer.getChildAt(i);

        tab.setLayoutParams(defaultTabLayoutParams);
        tab.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            tab.setPadding(0, 0, 0, 0);/*from   w ww .  jav  a 2 s.c  o  m*/
        } else {
            tab.setPadding(tabPadding, 0, tabPadding, 0);
        }
        tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        tab.setTypeface(tabTypeface, tabTypefaceStyle);
        tab.setTextColor(tabTextColor);

        // modified
        if (currentPosition == i) {
            tab.setTextColor(tabTextColorWhenSelected);
        } else {
            tab.setTextColor(tabTextColor);
        }
    }

}

From source file:com.applite.common.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from   ww  w .  j  a v  a  2 s  .co m*/
            }
            if (i == selectedPosition) {
                tab.setSelected(true);
            } else {
                tab.setSelected(false);
            }
        }
    }

}

From source file:com.xxjwd.libs.PagerSlidingTabStrip.java

 private void updateTabStyles() {

   for (int i = 0; i < tabCount; i++) {

      View v = tabsContainer.getChildAt(i);

      v.setLayoutParams(defaultTabLayoutParams);
      v.setBackgroundResource(tabBackgroundResId);
      if (shouldExpand) {
         v.setPadding(0, 0, 0, 0);//w ww. j ava  2  s .  com
      } else {
         v.setPadding(tabPadding, 0, tabPadding, 0);
      }

      if (v instanceof TextView) {

         TextView tab = (TextView) v;
         tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
         tab.setTypeface(tabTypeface, tabTypefaceStyle);
         tab.setTextColor(tabTextColor);

         // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
         // pre-ICS-build
         if (textAllCaps) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
               tab.setAllCaps(true);
            } else {
               tab.setText(tab.getText().toString().toUpperCase(locale));
            }
         }
      }
   }

}