Example usage for android.widget LinearLayout HORIZONTAL

List of usage examples for android.widget LinearLayout HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

To view the source code for android.widget LinearLayout HORIZONTAL.

Click Source Link

Usage

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private int getScrollerOffset() {
    if (this.orientation == LinearLayout.HORIZONTAL) {
        return mScroller.getCurrX();
    }/*from w ww  . j  a v a 2  s  .  c o  m*/

    return mScroller.getCurrY();
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private int getScrollerFinalOffset() {
    if (this.orientation == LinearLayout.HORIZONTAL) {
        return mScroller.getFinalX();
    }/*from   www . j  av  a2  s . c  o  m*/

    return mScroller.getFinalY();
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private float getMotionEventCoordinate(MotionEvent ev) {
    if (this.orientation == LinearLayout.HORIZONTAL) {
        return ev.getX();
    }/*  www.  ja v  a2s.  c om*/

    return ev.getY();
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private float getMotionEventCompatCoordinate(MotionEvent ev, int pointerIndex) {
    if (this.orientation == LinearLayout.HORIZONTAL) {
        return MotionEventCompat.getX(ev, pointerIndex);
    }//  w w w.  j a  v a2s  .co  m

    return MotionEventCompat.getY(ev, pointerIndex);
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private boolean getCanScroll(View v, int dx) {

    if (this.orientation == LinearLayout.HORIZONTAL) {
        return ViewCompat.canScrollHorizontally(v, -dx);
    }//w  w  w .j a  v  a2 s.c  o  m

    return ViewCompat.canScrollVertically(v, -dx);
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private int getClientLength() {
    if (this.orientation == LinearLayout.HORIZONTAL) {
        return this.getClientWidth();
    }//ww  w. ja va 2s. com

    return this.getClientHeight();
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void addGallery(final String[] imgUrls) {
    numGalleries++;//from  ww  w  .  j a  v  a 2s . c  o m
    if (!PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("load_imgs_pref", true)
            || numGalleries > Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity())
                    .getString("gallery_num_pref", "20")))
        return;
    HorizontalScrollView hsv = new HorizontalScrollView(getActivity());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER_HORIZONTAL;
    params.setMargins(10, 10, 10, 0);
    hsv.setLayoutParams(params);

    LinearLayout container = new LinearLayout(getActivity());
    container.setOrientation(LinearLayout.HORIZONTAL);
    for (int i = 0; i < imgUrls.length; i++) {
        final ImageView img = new ImageView(getActivity());
        LayoutParams imgPar = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        if (i == 0)
            imgPar.setMargins(5, 10, 0, 10);
        else
            imgPar.setMargins(10, 10, 0, 10);
        img.setLayoutParams(imgPar);
        img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        container.addView(img);

        final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(false)
                .cacheInMemory(true).showImageOnLoading(R.drawable.empty_cr).bitmapConfig(Bitmap.Config.RGB_565)
                .imageScaleType(ImageScaleType.EXACTLY).delayBeforeLoading(200).build();
        ImageLoader.getInstance().displayImage(imgUrls[i], img, options);

        final int k = i;
        img.setClickable(true);
        img.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(getActivity());
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.img_dialog_layout);
                ImageLoader.getInstance().displayImage(imgUrls[k].split("\\?resize=")[0],
                        ((TouchImageView) dialog.findViewById(R.id.dialog_image)), options);
                dialog.setCancelable(true);
                dialog.show();
            }
        });
    }
    hsv.addView(container);
    lay.addView(hsv);
}

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

private void addIndicator(TextView indicator, int index) {
    if (mIndicatorArea == null) {
        mIndicatorArea = new LinearLayout(getContext());
        mIndicatorArea.setOrientation(LinearLayout.HORIZONTAL);
        addView(mIndicatorArea, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

        // Add a flexible spacer in the middle so that the left/right views stay pinned
        final Space spacer = new Space(getContext());
        final LayoutParams spacerLp = new LayoutParams(0, 0, 1f);
        mIndicatorArea.addView(spacer, spacerLp);

        if (mEditText != null) {
            adjustIndicatorPadding();//from   w w  w  . j ava 2 s .c o  m
        }
    }
    mIndicatorArea.setVisibility(View.VISIBLE);
    mIndicatorArea.addView(indicator, index);
    mIndicatorsAdded++;
}

From source file:com.flipzu.flipzu.Recorder.java

@Override
public void onCommentsReceived(Hashtable<String, String>[] comments) {
    debug.logV(TAG, "onCommentsReceived");

    final LinearLayout cc = (LinearLayout) findViewById(R.id.comments_container);

    /* cleanup comments first */
    cc.removeAllViews();/* www  . j  a  va  2 s .  c o  m*/

    /* get pixel values for various DIPs */
    final float scale = getResources().getDisplayMetrics().density;
    //      final int pixel_10 = 10 / (int) (scale + 0.5f);
    final int pixel_5 = 5 / (int) (scale + 0.5f);
    //      final int pixel_30 = 30 / (int) (scale + 0.5f);
    final LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    if (comments != null && comments.length > 0) {

        for (int i = 0; i < comments.length; i++) {

            LinearLayout cl = new LinearLayout(Recorder.this);
            cl.setOrientation(LinearLayout.HORIZONTAL);
            cl.setPadding(0, 0, 0, pixel_5);

            debug.logD(TAG, "Refresher comment " + comments[i]);

            /* comment */
            TextView comment_tv = new TextView(Recorder.this);
            comment_tv.setLayoutParams(params);
            comment_tv.setText(comments[i].get("username") + ": " + comments[i].get("comment"),
                    TextView.BufferType.SPANNABLE);
            comment_tv.setTextColor(Color.parseColor("#656565"));
            Spannable comment_span = (Spannable) comment_tv.getText();
            comment_span.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0,
                    comment_tv.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            comment_span.setSpan(new ForegroundColorSpan(Color.parseColor("#182e5b")), 0,
                    comments[i].get("username").length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            comment_tv.setText(comment_span);
            cl.addView(comment_tv);

            cc.addView(cl);

        }

    } else {
        if (mState == recorderState.RECORDING) {
            String msg = "You're LIVE! Your broadcast can be heard at http://flipzu.com/" + mUser.getUsername();
            showFlipzuTipsOffline(cc, params, msg);
        } else {
            String msg = "Pick a good and descriptive broadcast title. A great title will attract more listeners!";
            showFlipzuTipsOffline(cc, params, msg);
            msg = "You can disable sharing in Twitter and Facebook by clicking the logo buttons. This is great for testing.";
            showFlipzuTipsOffline(cc, params, msg);
            msg = "Press the \"Start Broadcast\" button and let them hear you!";
            showFlipzuTipsOffline(cc, params, msg);
        }
    }
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private int getSwipeVelocity(VelocityTracker tracker, int pointerId) {
    if (this.orientation == LinearLayout.HORIZONTAL) {
        return (int) VelocityTrackerCompat.getXVelocity(tracker, pointerId);
    }/*  ww w  .  j a v  a  2  s. c  o m*/

    return (int) VelocityTrackerCompat.getYVelocity(tracker, pointerId);
}