Example usage for android.view View getPaddingRight

List of usage examples for android.view View getPaddingRight

Introduction

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

Prototype

public int getPaddingRight() 

Source Link

Document

Returns the right padding of this view.

Usage

From source file:io.jari.geenstijl.Blog.java

public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.blog);/*from  www.  j a v a 2 s  . c o m*/

    super.onCreate(savedInstanceState);

    actionBar = getSupportActionBar();
    final PullToRefreshLayout mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout);

    View drawer = findViewById(R.id.left_drawer);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerStateChanged(int newState) {
            super.onDrawerStateChanged(newState);
            enableImmersive(false, drawerLayout);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    if (Build.VERSION.SDK_INT >= 19) {
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        drawer.setPadding(drawer.getPaddingLeft(), drawer.getPaddingTop() + config.getPixelInsetTop(true),
                drawer.getPaddingRight(), drawer.getPaddingBottom());
    }
    ListView siteSwitch = (ListView) drawer.findViewById(R.id.site_switcher);
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.drawer_list_item,
            R.id.wrap_text, new String[] { "GeenStijl.nl", "GeenStijl.tv" });
    siteSwitch.setAdapter(arrayAdapter);
    siteSwitch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                API.setDomain("www.geenstijl.nl", Blog.this);
                break;
            case 1:
                API.setDomain("www.geenstijl.tv", Blog.this);
                break;
            }

            forceNoImmersive = true;
            enableImmersive(false, drawerLayout);
            drawerLayout.closeDrawers();
            mPullToRefreshLayout.setRefreshing(true);
            new Thread(new Runnable() {
                public void run() {
                    forceNoImmersive = true;
                    try {
                        final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext());
                        initUI(artikelen, false);
                        runOnUiThread(new Runnable() {
                            public void run() {
                                mPullToRefreshLayout.setRefreshComplete();
                                forceNoImmersive = false;
                            }
                        });
                    } catch (final Exception e) {
                        e.printStackTrace();
                        runOnUiThread(new Runnable() {
                            public void run() {
                                forceNoImmersive = false;
                                mPullToRefreshLayout.setRefreshComplete();
                                Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout"
                                        : e.getLocalizedMessage(), Style.ALERT).show();
                            }
                        });
                    }
                }
            }).start();
        }
    });

    ListView applist = (ListView) findViewById(R.id.applist);
    applist.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, R.id.wrap_text, new String[] {
            getResources().getString(R.string.options), getResources().getString(R.string.about) }));
    applist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                startActivity(new Intent(Intent.ACTION_VIEW, null, Blog.this, Settings.class));
                break;
            case 1:
                new AboutDialog(Blog.this).show(getSupportFragmentManager(), "AbtDlg");
                break;
            }
            drawerLayout.closeDrawers();
        }
    });

    reloadDrawer();

    // Now setup the PullToRefreshLayout
    ActionBarPullToRefresh.from(this).allChildrenArePullable().listener(new OnRefreshListener() {
        public void onRefreshStarted(View view) {
            new Thread(new Runnable() {
                public void run() {
                    forceNoImmersive = true;
                    try {
                        final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext());
                        initUI(artikelen, false);
                    } catch (final Exception e) {
                        e.printStackTrace();
                        runOnUiThread(new Runnable() {
                            public void run() {
                                forceNoImmersive = false;
                                mPullToRefreshLayout.setRefreshComplete();
                                Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout"
                                        : e.getLocalizedMessage(), Style.ALERT).show();
                            }
                        });
                    }
                }
            }).start();
        }
    }).setup(mPullToRefreshLayout);

    new Thread(new Runnable() {
        public void run() {
            try {
                final Artikel[] artikelen = API.getArticles(false, false, getApplicationContext());
                initUI(artikelen, true);
            } catch (final Exception e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        errorMessage = e.getMessage();
                        switchState(STATE_ERROR);
                    }
                });
            }
        }
    }).start();

    //do changelog stuff
    SharedPreferences sPref = this.getSharedPreferences("geenstijl", 0);
    int version = 0;
    try {
        version = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (PackageManager.NameNotFoundException ignored) {
    }

    //is changelog already read
    if (!sPref.getBoolean("changelog-" + version, false)) {
        //set changelog to read
        sPref.edit().putBoolean("changelog-" + version, true).commit();

        //show dialog
        LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.changelog, null);

        new AlertDialog.Builder(this).setTitle(R.string.changelog_title).setView(chgList)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                    }
                }).create().show();
    }

}

From source file:com.kyo.fitssystemwindows.FitsSystemWindowsFrameLayout.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final boolean applyInsets = lastInsets != null && ViewCompat.getFitsSystemWindows(this);
    final int layoutDirection = ViewCompat.getLayoutDirection(this);
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);

        if (child.getVisibility() == GONE) {
            continue;
        }/*from w w  w .ja va  2s  . co  m*/

        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (lp.gravity == -1) {
            lp.gravity = DEFAULT_CHILD_GRAVITY;
        }

        if (applyInsets) {
            int cgrav = GravityCompat.getAbsoluteGravity(lp.gravity, layoutDirection);

            if (cgrav == -1) {
                cgrav = DEFAULT_CHILD_GRAVITY;
            } else {
                if ((cgrav & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
                    cgrav = cgrav | Gravity.TOP;
                }
                if ((cgrav & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) {
                    cgrav = cgrav | (layoutDirection == LAYOUT_DIRECTION_LTR ? Gravity.LEFT : Gravity.RIGHT);
                }
            }

            if (ViewCompat.getFitsSystemWindows(child)) {
                final int l = child.getPaddingLeft();
                final int t = child.getPaddingTop();
                final int r = child.getPaddingRight();
                final int b = child.getPaddingBottom();
                IMPL.dispatchChildInsets(child, lp, cgrav, lastInsets);
                child.setPadding(l, t, r, b);
            } else {
                IMPL.applyMarginInsets(lp, cgrav, lastInsets);
                lp.leftMargin += lp.leftMargin2;
                lp.topMargin += lp.topMargin2;
                lp.rightMargin += lp.rightMargin2;
                lp.bottomMargin += lp.bottomMargin2;
            }
        }
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE || ViewCompat.getFitsSystemWindows(child)) {
            continue;
        }
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        lp.leftMargin -= lp.leftMargin2;
        lp.topMargin -= lp.topMargin2;
        lp.rightMargin -= lp.rightMargin2;
        lp.bottomMargin -= lp.bottomMargin2;
    }
}

From source file:it.gmariotti.cardslib.library.view.CardViewNative.java

protected void setupExpandAction() {

    //Config ExpandLayout and its animation
    if (mInternalExpandLayout != null && ((mCardHeader != null && mCardHeader.isButtonExpandVisible())
            || mCard.getViewToClickToExpand() != null)) {

        //Create the expand/collapse animator
        mInternalExpandLayout.getViewTreeObserver()
                .addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                    @Override/*ww w  .  j  av a 2s  .  c  o  m*/
                    public boolean onPreDraw() {
                        mInternalExpandLayout.getViewTreeObserver().removeOnPreDrawListener(this);

                        View parent = (View) mInternalExpandLayout.getParent();
                        final int widthSpec = View.MeasureSpec.makeMeasureSpec(
                                parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(),
                                View.MeasureSpec.AT_MOST);
                        final int heightSpec = View.MeasureSpec.makeMeasureSpec(0,
                                View.MeasureSpec.UNSPECIFIED);
                        mInternalExpandLayout.measure(widthSpec, heightSpec);

                        mExpandAnimator = ExpandCollapseHelper.createSlideAnimator(
                                (CardViewNative) mCard.getCardView(), 0,
                                mInternalExpandLayout.getMeasuredHeight());
                        return true;
                    }
                });
    }

    //Setup action and callback
    setupExpandCollapseActionListener();
}

From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java

/**
 * Sets the width of the dialog. Also called when configuration changes.
 *//*from   www.j a va2s  . c o m*/
void updateLayout() {
    int width = MediaRouteDialogHelper.getDialogWidth(mContext);
    getWindow().setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT);

    View decorView = getWindow().getDecorView();
    mDialogContentWidth = width - decorView.getPaddingLeft() - decorView.getPaddingRight();

    Resources res = mContext.getResources();
    mVolumeGroupListItemIconSize = res
            .getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_item_icon_size);
    mVolumeGroupListItemHeight = res.getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_item_height);
    mVolumeGroupListMaxHeight = res.getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_max_height);

    // Fetch art icons again for layout changes to resize it accordingly
    mArtIconBitmap = null;
    mArtIconUri = null;
    updateArtIconIfNeeded();
    update(false);
}

From source file:com.andrada.sitracker.ui.fragment.PublicationInfoFragment.java

private void showCustomPositionedCrouton(String message, boolean success) {
    if (getActivity() == null) {
        return;/*from   w w w .j  av  a  2  s . c o m*/
    }
    View view = getLayoutInflater(null).inflate(R.layout.crouton_custom_pos_textview, null);
    if (success) {
        view.findViewById(android.R.id.background).setBackgroundColor(Style.holoGreenLight);
    } else {
        view.findViewById(android.R.id.background).setBackgroundColor(Style.holoRedLight);
    }
    int topPadding = UIUtils.calculateActionBarSize(getActivity());
    if (!mHasPhoto) {
        topPadding = (int) (newTop + mHeaderHeightPixels);
    }
    view.setPadding(view.getPaddingLeft(), topPadding, view.getPaddingRight(), view.getPaddingBottom());
    TextView tv = (TextView) view.findViewById(android.R.id.text1);
    tv.setText(message);
    Crouton cr = Crouton.make(getActivity(), view);
    cr.setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_LONG).build());
    cr.show();
}

From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java

@Override
public void onDestroyActionMode(ActionMode mode) {
    final Window window = getWindow();
    final View contentView = window.findViewById(android.R.id.content);
    contentView.setPadding(contentView.getPaddingLeft(), 0, contentView.getPaddingRight(),
            contentView.getPaddingBottom());
}

From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java

private View makeHeader(ViewGroup parent, boolean button, float density) {
    if (C.API_LOLLIPOP) {
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        View divider = makeSimpleDivider();
        int paddingTop = divider.getPaddingBottom();
        divider.setPadding(divider.getPaddingLeft(), divider.getPaddingTop(), divider.getPaddingRight(), 0);
        linearLayout.addView(divider, LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        LinearLayout linearLayout2 = new LinearLayout(context);
        linearLayout2.setOrientation(LinearLayout.HORIZONTAL);
        linearLayout.addView(linearLayout2, LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        TextView textView = makeCommonTextView(true);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, (int) (32f * density), 1);
        layoutParams.setMargins((int) (16f * density), paddingTop, (int) (16f * density), (int) (8f * density));
        linearLayout2.addView(textView, layoutParams);
        ViewHolder holder = new ViewHolder();
        holder.text = textView;//from  www .j  a va2s  .  co m
        if (button) {
            ImageView imageView = new ImageView(context);
            imageView.setScaleType(ImageView.ScaleType.CENTER);
            imageView.setBackgroundResource(ResourceUtils.getResourceId(context,
                    android.R.attr.borderlessButtonStyle, android.R.attr.background, 0));
            imageView.setOnClickListener(headerButtonListener);
            imageView.setImageAlpha(0x5e);
            int size = (int) (48f * density);
            layoutParams = new LinearLayout.LayoutParams(size, size);
            layoutParams.rightMargin = (int) (4f * density);
            linearLayout2.addView(imageView, layoutParams);
            holder.extra = imageView;
            holder.icon = imageView;
        }
        linearLayout.setTag(holder);
        return linearLayout;
    } else {
        View view = LayoutInflater.from(context)
                .inflate(ResourceUtils.getResourceId(context, android.R.attr.preferenceCategoryStyle,
                        android.R.attr.layout, android.R.layout.preference_category), parent, false);
        ViewHolder holder = new ViewHolder();
        holder.text = (TextView) view.findViewById(android.R.id.title);
        if (button) {
            int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
            view.measure(measureSpec, measureSpec);
            int size = view.getMeasuredHeight();
            if (size == 0) {
                size = (int) (32f * density);
            }
            FrameLayout frameLayout = new FrameLayout(context);
            frameLayout.addView(view);
            view = frameLayout;
            ImageView imageView = new ImageView(context);
            imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            int padding = (int) (4f * density);
            imageView.setPadding(padding, padding, padding, padding);
            frameLayout.addView(imageView,
                    new FrameLayout.LayoutParams((int) (48f * density), size, Gravity.END));
            View buttonView = new View(context);
            buttonView.setBackgroundResource(
                    ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0));
            buttonView.setOnClickListener(headerButtonListener);
            frameLayout.addView(buttonView, FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT);
            holder.extra = buttonView;
            holder.icon = imageView;
        }
        view.setTag(holder);
        return view;
    }
}

From source file:lewa.support.v7.internal.widget.ActionBarContextView.java

public void initForMode(final ActionMode mode) {
    ///LEWA BEGIN
    mActionMode = mode;/*from   ww  w .  ja v  a  2s  . c om*/

    if (mClose == null) {
        LayoutInflater inflater = LayoutInflater.from(getContext());
        mClose = inflater.inflate(R.layout.action_mode_close_item, this, false);
        addView(mClose);
    } else if (mClose.getParent() == null) {
        addView(mClose);
    }

    View closeButton = mClose.findViewById(R.id.action_mode_close_button);
    closeButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mode.finish();
        }
    });

    closeButton.setBackgroundColor(0);
    closeButton.setOnTouchListener(new InjectorTouchListener());
    closeButton.setPadding(closeButton.getPaddingLeft(), mStatusbarHeight, closeButton.getPaddingRight(),
            closeButton.getPaddingBottom());

    final MenuBuilder menu = (MenuBuilder) mode.getMenu();
    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.dismissPopupMenus();
    }

    ///LEWA BEGIN
    mSplitActionBar = true;
    if (mSplitActionBar) {
        mActionMenuPresenter = new LewaActionMenuPresenter(getContext());
        // Set action mode for change style of action mode.
        ((LewaActionMenuPresenter) mActionMenuPresenter).setActionMode(true);
    } else {
        mActionMenuPresenter = new ActionMenuPresenter(getContext());
    }
    ///LEWA END
    mActionMenuPresenter.setReserveOverflow(true);

    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    if (!mSplitActionBar) {
        menu.addMenuPresenter(mActionMenuPresenter, mPopupContext);
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(null);
        addView(mMenuView, layoutParams);
    } else {
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.MATCH_PARENT;
        layoutParams.height = mContentHeight;
        ///LEWA BEGIN
        int actionbarHeight = ActionBarPolicy.get(getContext()).getTabContainerHeight();
        layoutParams.height = actionbarHeight;
        ///LEWA END
        menu.addMenuPresenter(mActionMenuPresenter, mPopupContext);
        // create menu view in by menu presenter
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(mSplitBackground);

        // LEWA ADD START
        // Add menu bar into action mode.
        addActionModeOptionMenu(this, menu, layoutParams);
        if (true) {
        } else {
            mSplitView.addView(mMenuView, layoutParams);
        }
        // LEWA ADD END
    }

    mAnimateInOnLayout = true;
}

From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    final Window window = getWindow();
    final Rect rect = new Rect();
    window.getDecorView().getWindowVisibleDisplayFrame(rect);
    final View contentView = window.findViewById(android.R.id.content);
    final int statusBarHeight = rect.top;
    contentView.getWindowVisibleDisplayFrame(rect);
    final int paddingTop = statusBarHeight + Utils.getActionBarHeight(this) - rect.top;
    contentView.setPadding(contentView.getPaddingLeft(), paddingTop, contentView.getPaddingRight(),
            contentView.getPaddingBottom());
    return true;/*www.  j a v a 2  s . c  om*/
}

From source file:org.mariotaku.twidere.activity.support.ComposeActivity.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    final Window window = getWindow();
    final Rect rect = new Rect();
    window.getDecorView().getWindowVisibleDisplayFrame(rect);
    final int actionBarHeight = ThemeUtils.getActionBarHeight(this);
    final View contentView = window.findViewById(android.R.id.content);
    final int[] location = new int[2];
    contentView.getLocationOnScreen(location);
    if (location[1] > actionBarHeight) {
        contentView.setPadding(contentView.getPaddingLeft(), 0, contentView.getPaddingRight(),
                contentView.getPaddingBottom());
        return true;
    }//from  w w  w. j  av  a 2s .com
    final int statusBarHeight = rect.top;
    contentView.getWindowVisibleDisplayFrame(rect);
    final int paddingTop = statusBarHeight + actionBarHeight - rect.top;
    contentView.setPadding(contentView.getPaddingLeft(), paddingTop, contentView.getPaddingRight(),
            contentView.getPaddingBottom());
    return true;
}