Example usage for android.view View setPadding

List of usage examples for android.view View setPadding

Introduction

In this page you can find the example usage for android.view View setPadding.

Prototype

public void setPadding(int left, int top, int right, int bottom) 

Source Link

Document

Sets the padding.

Usage

From source file:com.visk.xperiatuner.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        if (v != null) {
            v.setLayoutParams(defaultTabLayoutParams);
            v.setBackgroundResource(tabBackgroundResId);

            if (shouldExpand) {
                v.setPadding(0, 0, 0, 0);
            } else {
                v.setPadding(tabPadding, 0, tabPadding, 0);
            }/*from   w w  w  .j av a 2 s . co m*/
        }
        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() + "".toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.ashish.routofy.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            // 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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }//from   w  ww. ja  v  a2s .  c o  m
            }
        }
    }
}

From source file:cn.liucl.stationarytabstrip.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);/*from www. j a v  a  2s.co  m*/
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    if (position == 0) {
        headsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
    } else {
        tabsContainer.addView(tab, position - 1,
                shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
    }
}

From source file:com.iphonmusic.style.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//from w ww.j  ava  2  s. co  m
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (pager != null) {
                pager.setCurrentItem(position);
            }
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java

@SuppressLint("RtlHardcoded")
@SuppressWarnings("deprecation")
@Override/*  w ww  .  java 2s. co  m*/
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    LocalBroadcastManager.getInstance(this)
            .sendBroadcast(new Intent("com.farmerbb.taskbar.CONTEXT_MENU_APPEARING"));

    boolean isNonAppMenu = !getIntent().hasExtra("package_name") && !getIntent().hasExtra("app_name");
    showStartMenu = getIntent().getBooleanExtra("launched_from_start_menu", false);
    isStartButton = isNonAppMenu && getIntent().getBooleanExtra("is_start_button", false);
    isOverflowMenu = isNonAppMenu && getIntent().getBooleanExtra("is_overflow_menu", false);
    contextMenuFix = getIntent().hasExtra("context_menu_fix");

    // Determine where to position the dialog on screen
    WindowManager.LayoutParams params = getWindow().getAttributes();
    DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE);
    Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);

    int statusBarHeight = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0)
        statusBarHeight = getResources().getDimensionPixelSize(resourceId);

    if (showStartMenu) {
        int x = getIntent().getIntExtra("x", 0);
        int y = getIntent().getIntExtra("y", 0);
        int offset = getResources().getDimensionPixelSize(
                isOverflowMenu ? R.dimen.context_menu_offset_overflow : R.dimen.context_menu_offset);

        switch (U.getTaskbarPosition(this)) {
        case "bottom_left":
        case "bottom_vertical_left":
            params.gravity = Gravity.BOTTOM | Gravity.LEFT;
            params.x = x;
            params.y = display.getHeight() - y - offset;
            break;
        case "bottom_right":
        case "bottom_vertical_right":
            params.gravity = Gravity.BOTTOM | Gravity.LEFT;
            params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset;
            params.y = display.getHeight() - y - offset;
            break;
        case "top_left":
        case "top_vertical_left":
            params.gravity = Gravity.TOP | Gravity.LEFT;
            params.x = x;
            params.y = y - offset + statusBarHeight;
            break;
        case "top_right":
        case "top_vertical_right":
            params.gravity = Gravity.TOP | Gravity.LEFT;
            params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset;
            params.y = y - offset + statusBarHeight;
            break;
        }
    } else {
        LocalBroadcastManager.getInstance(this)
                .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));

        int x = getIntent().getIntExtra("x", display.getWidth());
        int y = getIntent().getIntExtra("y", display.getHeight());
        int offset = getResources().getDimensionPixelSize(R.dimen.icon_size);

        switch (U.getTaskbarPosition(this)) {
        case "bottom_left":
            params.gravity = Gravity.BOTTOM | Gravity.LEFT;
            params.x = isStartButton ? 0 : x;
            params.y = offset;
            break;
        case "bottom_vertical_left":
            params.gravity = Gravity.BOTTOM | Gravity.LEFT;
            params.x = offset;
            params.y = display.getHeight() - y - (isStartButton ? 0 : offset);
            break;
        case "bottom_right":
            params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
            params.x = display.getWidth() - x;
            params.y = offset;
            break;
        case "bottom_vertical_right":
            params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
            params.x = offset;
            params.y = display.getHeight() - y - (isStartButton ? 0 : offset);
            break;
        case "top_left":
            params.gravity = Gravity.TOP | Gravity.LEFT;
            params.x = isStartButton ? 0 : x;
            params.y = offset;
            break;
        case "top_vertical_left":
            params.gravity = Gravity.TOP | Gravity.LEFT;
            params.x = offset;
            params.y = isStartButton ? 0 : y - statusBarHeight;
            break;
        case "top_right":
            params.gravity = Gravity.TOP | Gravity.RIGHT;
            params.x = display.getWidth() - x;
            params.y = offset;
            break;
        case "top_vertical_right":
            params.gravity = Gravity.TOP | Gravity.RIGHT;
            params.x = offset;
            params.y = isStartButton ? 0 : y - statusBarHeight;
            break;
        }
    }

    params.width = getResources().getDimensionPixelSize(R.dimen.context_menu_width);
    params.dimAmount = 0;

    getWindow().setAttributes(params);

    View view = findViewById(android.R.id.list);
    if (view != null)
        view.setPadding(0, 0, 0, 0);

    generateMenu();

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("com.farmerbb.taskbar.START_MENU_APPEARING");
    intentFilter.addAction("com.farmerbb.taskbar.DASHBOARD_APPEARING");

    LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, intentFilter);
}

From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java

private void addTab(final int position, final View tab) {
    tab.setFocusable(true);/*from   w w w.j  ava2s  .co m*/
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
            checkBackground(position);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.hcpt.fastfood.widget.PagerSlidingTabStrip.java

private void addTab(final int position, final View tab) {
    tab.setFocusable(true);//from w  w  w . j  a v  a  2  s  .com
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tab.setPadding(tabPadding, 10, tabPadding, 1);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
    tabsList.add(tab);
}

From source file:android.support.design.widget.BaseTransientBottomBar.java

/**
 * Constructor for the transient bottom bar.
 *
 * @param parent The parent for this transient bottom bar.
 * @param content The content view for this transient bottom bar.
 * @param contentViewCallback The content view callback for this transient bottom bar.
 *//*from  ww  w  . j a v a 2 s.  c o m*/
protected BaseTransientBottomBar(@NonNull ViewGroup parent, @NonNull View content,
        @NonNull ContentViewCallback contentViewCallback) {
    if (parent == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null parent");
    }
    if (content == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null content");
    }
    if (contentViewCallback == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null callback");
    }

    mTargetParent = parent;
    mContentViewCallback = contentViewCallback;
    mContext = parent.getContext();

    ThemeUtils.checkAppCompatTheme(mContext);

    LayoutInflater inflater = LayoutInflater.from(mContext);
    // Note that for backwards compatibility reasons we inflate a layout that is defined
    // in the extending Snackbar class. This is to prevent breakage of apps that have custom
    // coordinator layout behaviors that depend on that layout.
    mView = (SnackbarBaseLayout) inflater.inflate(R.layout.design_layout_snackbar, mTargetParent, false);
    mView.addView(content);

    ViewCompat.setAccessibilityLiveRegion(mView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(mView, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    ViewCompat.setFitsSystemWindows(mView, true);
    ViewCompat.setOnApplyWindowInsetsListener(mView, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            // Copy over the bottom inset as padding so that we're displayed
            // above the navigation bar
            v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
                    insets.getSystemWindowInsetBottom());
            return insets;
        }
    });

    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}

From source file:com.astuetz.PagerSlidingTabStripMenu.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);/*w w w  . ja  va  2s . com*/
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tab.setPadding(tabPadding, mTabPaddingTop, tabPadding, mTabPaddingBottom);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.ghkjgod.lightnovel.component.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }/* w w w  .  jav  a 2s  .  com*/
            // 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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}