Example usage for android.view View getPaddingLeft

List of usage examples for android.view View getPaddingLeft

Introduction

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

Prototype

public int getPaddingLeft() 

Source Link

Document

Returns the left padding of this view.

Usage

From source file:com.xabber.android.ui.adapter.ChatMessageAdapter.java

private void setUpMessageBalloonBackground(View messageBalloon, ColorStateList darkColorStateList,
        int lightBackgroundId) {

    if (SettingsManager.interfaceTheme() == SettingsManager.InterfaceTheme.dark) {
        final Drawable originalBackgroundDrawable = messageBalloon.getBackground();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            originalBackgroundDrawable.setTintList(darkColorStateList);
        } else {/*  w w  w . j  a v a2 s.  com*/
            Drawable wrapDrawable = DrawableCompat.wrap(originalBackgroundDrawable);
            DrawableCompat.setTintList(wrapDrawable, darkColorStateList);

            int pL = messageBalloon.getPaddingLeft();
            int pT = messageBalloon.getPaddingTop();
            int pR = messageBalloon.getPaddingRight();
            int pB = messageBalloon.getPaddingBottom();

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                messageBalloon.setBackground(wrapDrawable);
            } else {
                messageBalloon.setBackgroundDrawable(wrapDrawable);
            }

            messageBalloon.setPadding(pL, pT, pR, pB);
        }
    } else {
        int pL = messageBalloon.getPaddingLeft();
        int pT = messageBalloon.getPaddingTop();
        int pR = messageBalloon.getPaddingRight();
        int pB = messageBalloon.getPaddingBottom();

        messageBalloon.setBackgroundResource(lightBackgroundId);
        messageBalloon.getBackground().setLevel(AccountManager.getInstance().getColorLevel(account));
        messageBalloon.setPadding(pL, pT, pR, pB);
    }
}

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

public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.blog);/*from  ww w  .java 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;
        }/* w  w  w. j  a v a  2s.  c o  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:android.support.v7.app.MediaRouteControllerDialog.java

/**
 * Sets the width of the dialog. Also called when configuration changes.
 *//*  w  ww. j av a2s .  co  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);

    // Ensure the mArtView is updated.
    mArtIconBitmap = null;
    mArtIconUri = null;
    update(false);
}

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/*from w  ww.ja  v  a2  s .  c om*/
                    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.
 *//*  w  ww  .  j  ava  2 s  .com*/
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  a2  s  . com
    }
    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:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterListView.java

/**
 * Create shadow wrapper with a sticky view  at given position
 *///  w  ww  .ja va 2  s . com
void createStickyShadow(int position) {

    // recycle shadow
    StickyWrapper stickyViewShadow = recycledHeaderView;
    recycledHeaderView = null;

    // create new shadow, if needed
    if (stickyViewShadow == null) {
        stickyViewShadow = new StickyWrapper();
    }
    // request new view using recycled view, if such
    View stickyView = getAdapter().getView(position, stickyViewShadow.view, MessageCenterListView.this);

    // read layout parameters
    LayoutParams layoutParams = (LayoutParams) stickyView.getLayoutParams();
    if (layoutParams == null) {
        layoutParams = (LayoutParams) generateDefaultLayoutParams();
        stickyView.setLayoutParams(layoutParams);
    }

    View childLayout = ((ViewGroup) stickyView).getChildAt(0);
    int heightMode = MeasureSpec.getMode(layoutParams.height);
    int heightSize = MeasureSpec.getSize(layoutParams.height);

    if (heightMode == MeasureSpec.UNSPECIFIED) {
        heightMode = MeasureSpec.EXACTLY;
    }

    int maxHeight = getHeight() - getListPaddingTop() - getListPaddingBottom();
    if (heightSize > maxHeight) {
        heightSize = maxHeight;
    }
    // assuming left and right additional paddings are the same
    int ws = MeasureSpec.makeMeasureSpec(getWidth() - getListPaddingLeft() - getListPaddingRight(),
            MeasureSpec.EXACTLY);
    int hs = MeasureSpec.makeMeasureSpec(heightSize, heightMode);
    stickyView.measure(ws, hs);
    stickyView.layout(0, 0, stickyView.getMeasuredWidth(), stickyView.getMeasuredHeight());

    // initialize shadow
    stickyViewShadow.view = stickyView;
    stickyViewShadow.position = position;
    stickyViewShadow.id = getAdapter().getItemId(position);
    stickyViewShadow.additionalIndent = childLayout.getPaddingLeft();

    stickyWrapper = stickyViewShadow;
}

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;/*  w ww .ja v a2s  . com*/
        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;
    }
}