Example usage for android.util TypedValue TypedValue

List of usage examples for android.util TypedValue TypedValue

Introduction

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

Prototype

TypedValue

Source Link

Usage

From source file:acc.healthapp.tabs.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*w  w  w .j  a  v  a2s  .c  o m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.indev.calculator.widget.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from ww  w.j av  a 2s .c om*/
 */

protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.example.slidingTabBasic.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from w  w w  .  ja v  a2s .co m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTextColor(Color.parseColor("#FFFFFF"));
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);
    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    return textView;
}

From source file:com.guerinet.materialtabs.TabLayout.java

/**
 * @return The default background to use
 *//*from  w  ww .  j  a  va 2  s.  c o m*/
private int getTabBackground() {
    TypedValue outValue = new TypedValue();

    if (mDefaultSelectorId == null) {
        //If we are in API 10 and a selector has not been set, throw an exception
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            throw new IllegalStateException("API 10 must have the default selector set");
        } else {
            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        }
    } else {
        //Use the set selector Id
        getContext().getTheme().resolveAttribute(mDefaultSelectorId, outValue, true);
    }
    return outValue.resourceId;
}

From source file:com.example.zapbuild.baseclasses.util.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.// ww  w  .ja v a2  s . c  o  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);

    //        textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.example.sgenclub.kings_speech.Helper.layout.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.// w w  w .  ja  v  a2 s  .c o m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    textView.setTextSize(15);
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.example.google.walkway.MainActivity.java

@SuppressLint("InlinedApi")
@Override//  ww  w .ja va2s  . c  o  m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    setContentView(R.layout.activity_main);

    mSelectedPlaceTypes.addAll(Arrays.asList(NAV_PLACE_TYPES));
    mPlaces = retrievePlaces();

    setupMapIfNeeded();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.app_name,
            R.string.app_name) {

        public void onDrawerClosed(View view) {
            // getActionBar().setTitle(mTitle);

            if (view.equals(mNavListView)) {
                // XXX no need to recreate the markers if the place
                // types haven't changed.
                mMap.clear();
                mPlaces = retrievePlaces();

                if (mPlaceViewPager != null) {
                    mPlaceViewPager.getAdapter().notifyDataSetChanged();
                    mPlaceViewPager.requestLayout();
                }

                addPlacesToMap();
                setSelectedPlace(0);
                showPlacesOnMap(true); // overrides animation from
                                       // setSelectedPlace
                setupPlaceList();
            }
        }

        public void onDrawerOpened(View drawerView) {
            // getActionBar().setTitle(mDrawerTitle);
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    setupPlaceViewPager();
    setupPlaceList();
    setupNavList();

    // Set the map padding once the UI views have dimensions.
    ViewTreeObserver observer = mDrawerLayout.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            removeListener();

            // Pad the top of the map to accommodate the transparent action
            // bar.
            TypedValue tv = new TypedValue();
            int actionbarHeight = 0;
            if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
                actionbarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
                        getResources().getDisplayMetrics());
            }

            // Pad the bottom of the map to accommodate the place viewpager.
            int viewPagerHeight = 0;
            if (mPlaceViewPager != null) {
                viewPagerHeight = mPlaceViewPager.getHeight();
            }

            // If the place list isn't in a DrawerLayout, pad the map for it.
            int placeListWidth = 0;
            // Use if listview overlays map.
            //                if (mPlaceListView.getVisibility() == View.VISIBLE) {
            //                    placeListWidth = mPlaceListView.getWidth();
            //                }

            mMap.setPadding(0, actionbarHeight, placeListWidth, viewPagerHeight);

            // Once the map is ready, add the markers to it.
            addPlacesToMap();
            showPlacesOnMap(false);
            setSelectedPlace(0);
        }

        @SuppressWarnings("deprecation")
        @SuppressLint("NewApi")
        private void removeListener() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                mDrawerLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            } else {
                mDrawerLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }
        }
    });
}

From source file:com.grarak.kerneladiutor.elements.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from  www  . j av a2  s.c o  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.fobae.android.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from  w  w  w  .j av a  2 s .c  o m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setTextColor(getResources().getColor(R.color.textPrimaryToolbar));
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.fimagena.filepicker.FilePickerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.picker_actions, menu);
    MenuItem item = menu.findItem(R.id.action_createdir);
    item.setVisible(mParams.get(ALLOW_CREATE_DIR));

    // FIXME: Ensure the icon is visible on the light background. This is a hack and should be done through the theme!
    TypedValue value = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.colorAccent, value, true);
    menu.findItem(R.id.action_createdir).getIcon().mutate().setColorFilter(value.data,
            PorterDuff.Mode.SRC_ATOP);//from w  ww.j ava  2s.  c  o  m

    for (int root = 0; root < mFileSystemRoots.length; root++)
        menu.add(Menu.NONE, root, Menu.NONE, "Switch to " + mFileSystemRoots[root].getName());
}