Example usage for android.widget LinearLayout setDividerDrawable

List of usage examples for android.widget LinearLayout setDividerDrawable

Introduction

In this page you can find the example usage for android.widget LinearLayout setDividerDrawable.

Prototype

public void setDividerDrawable(Drawable divider) 

Source Link

Document

Set a drawable to be used as a divider between items.

Usage

From source file:com.seraphim.chips.ChipsVerticalLinearLayout.java

private LinearLayout createHorizontalView() {
    LinearLayout ll = new LinearLayout(getContext());
    ll.setPadding(0, 0, 0, rowSpacing);/*from   w  w  w  .j a  v  a2s .co  m*/
    ll.setOrientation(HORIZONTAL);
    ll.setDividerDrawable(ContextCompat.getDrawable(getContext(), R.drawable.amc_empty_vertical_divider));
    ll.setShowDividers(SHOW_DIVIDER_MIDDLE);
    addView(ll);
    lineLayouts.add(ll);
    return ll;
}

From source file:rus.cpuinfo.Ui.Fragments.Base.CpuInfoBaseTabFragment.java

@Nullable
@Override/*from   w w  w .  ja  va 2 s.  co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_tab, container, false);
    ButterKnife.bind(this, v);

    mViewPager.setAdapter(createAdapter());
    mTabLayout.setupWithViewPager(mViewPager);

    View root = mTabLayout.getChildAt(0);

    if (root instanceof LinearLayout) {

        LinearLayout linearLayout = ((LinearLayout) root);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);

        GradientDrawable drawable = new GradientDrawable();
        drawable.setSize(2, 0);

        linearLayout.setDividerDrawable(drawable);
    }

    if (savedInstanceState != null) {
        mCurrentItem = savedInstanceState.getInt(SELECTED_TAB);
    }

    return v;
}

From source file:edu.ptu.navpattern.tooltip.Tooltip.java

private View getContentView(final Builder builder) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(builder.mBackgroundColor);
    drawable.setCornerRadius(builder.mCornerRadius);
    LinearLayout vgContent = new LinearLayout(builder.mContext);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        vgContent.setBackground(drawable);
    } else {//from  ww  w . j a  v  a 2  s.  c  om
        //noinspection deprecation
        vgContent.setBackgroundDrawable(drawable);
    }
    int padding = (int) builder.mPadding;
    vgContent.setPadding(padding, padding, padding, padding);
    vgContent.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
    textViewParams.gravity = Gravity.CENTER;
    textViewParams.topMargin = 1;
    vgContent.setLayoutParams(textViewParams);
    vgContent.setDividerDrawable(vgContent.getResources().getDrawable(R.drawable.divider_line));
    vgContent.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);

    if (builder.itemText != null && builder.itemText.length > 0) {
        for (int i = 0; i < builder.itemText.length; i++) {

            TextView textView = new TextView(builder.mContext);
            textView.setText(builder.itemText[i]);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 44);
            textView.setTextColor(0xffffffff);
            textView.setGravity(Gravity.CENTER_VERTICAL);
            if (builder.itemLogo != null && builder.itemLogo.length > i) {
                Drawable drawableLeft = builder.mContext.getResources().getDrawable(builder.itemLogo[i]);
                /// ??,??.
                //                    drawableLeft.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                //                    textView.setCompoundDrawables(drawableLeft, null, null, null);
                //                    textView.setCompoundDrawablePadding(4);
                //                    textView.setBackgroundDrawable(drawableLeft);
                LinearLayout linearLayout = new LinearLayout(builder.mContext);
                linearLayout.setMinimumHeight((int) dpToPx(44f));
                linearLayout.setOrientation(LinearLayout.HORIZONTAL);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                ImageView icon = new ImageView(builder.mContext);
                icon.setImageDrawable(drawableLeft);
                linearLayout.addView(icon);
                linearLayout.addView(textView);
                vgContent.addView(linearLayout);
                final int position = i;
                linearLayout.setClickable(false);
                linearLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (builder.mOnItemClickListener != null) {
                            builder.mOnItemClickListener.onClick(position);
                        }
                        mTouchListener.onTouch(v,
                                MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
                                        MotionEvent.ACTION_UP, v.getLeft() + 5, v.getTop() + 5, 0));
                    }
                });
            } else {
                vgContent.addView(textView);
                final int position = i;
                textView.setClickable(false);
                textView.setMinimumHeight((int) dpToPx(44f));
                textView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (builder.mOnItemClickListener != null) {
                            builder.mOnItemClickListener.onClick(position);
                        }
                        mTouchListener.onTouch(v, null);
                    }
                });
            }
        }

    }

    mArrowView = new ImageView(builder.mContext);
    mArrowView.setImageDrawable(builder.mArrowDrawable);

    LinearLayout.LayoutParams arrowLayoutParams;
    if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) {
        arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowWidth, (int) builder.mArrowHeight,
                0);
    } else {
        arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowHeight, (int) builder.mArrowWidth,
                0);
    }
    arrowLayoutParams.gravity = Gravity.CENTER;
    mArrowView.setLayoutParams(arrowLayoutParams);

    mContentView = new LinearLayout(builder.mContext);
    mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mContentView.setOrientation(mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayout.HORIZONTAL
            : LinearLayout.VERTICAL);

    padding = (int) dpToPx(5);

    switch (mGravity) {
    case Gravity.START:
        mContentView.setPadding(0, 0, padding, 0);
        break;
    case Gravity.TOP:
    case Gravity.BOTTOM:
        mContentView.setPadding(padding, 0, padding, 0);
        break;
    case Gravity.END:
        mContentView.setPadding(padding, 0, 0, 0);
        break;
    }

    if (mGravity == Gravity.TOP || mGravity == Gravity.START) {
        mContentView.addView(vgContent);
        mContentView.addView(mArrowView);
    } else {
        mContentView.addView(mArrowView);
        mContentView.addView(vgContent);
    }

    if (builder.isCancelable || builder.isDismissOnClick) {
        mContentView.setOnTouchListener(mTouchListener);
    }
    return mContentView;
}

From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Called when the device configuration changes.
 *///from  w  ww  .j a va 2  s . co  m
@Override
public void onConfigurationChanged(Configuration newConfig) {
    Log.d(LOG, LOG + ".onConfigurationChanged");
    super.onConfigurationChanged(newConfig);

    // Signal to the Governor that a runtime change has occurred.
    governor.onRuntimeChange();

    // Change the orientation of the PanelsLayout accordingly.
    LinearLayout panelsLayout = (LinearLayout) findViewById(R.id.PanelsLayout);
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        panelsLayout.setOrientation(LinearLayout.VERTICAL);
    } else {
        panelsLayout.setOrientation(LinearLayout.HORIZONTAL);
    }

    // Set the divider again, because it needs to be redrawn due to the orientation change.
    panelsLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.divider_panels));

    // Inform ActionBar Drawer Toggle of the change.
    actionBarDrawerToggle.onConfigurationChanged(newConfig);
}