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.little.pager.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);/*from   w w  w  .  j  a v  a 2s.co m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    //?????dpsp
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    //?
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstIndicatorColor, indicatorColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstIndicatorHeight,
            indicatorHeight);

    tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstTextSize, tabTextSize);
    tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstTextColor, tabTextColor);

    selectedTabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstSelectedTabTextSize,
            selectedTabTextSize);
    selectedTabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstSelectedTabTextColor,
            selectedTabTextColor);

    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstUnderlineColor, underlineColor);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstUnderlineHeight,
            underlineHeight);

    hasDivier = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstHasDivider, hasDivier);
    hasFollowColor = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstSameColor, hasDivier);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstDividerColor, dividerColor);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstDividerPadding,
            dividerPadding);

    colorArrayId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstColorArray, colorArrayId);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstTabPaddingLeftRight, tabPadding);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstTextAllCaps, textAllCaps);

    a.recycle();

    if (colorArrayId != 0) {
        try {
            colorArray = getResources().obtainTypedArray(colorArrayId);
        } catch (Exception e) {
            colorArray = null;
        }
    }
    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    //
    if (hasDivier) {
        dividerPaint = new Paint();
        dividerPaint.setAntiAlias(true);
        dividerPaint.setStrokeWidth(dividerWidth);
    }

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:it.iziozi.iziozi.gui.IOBoardFragment.java

private View buildView(boolean editMode) {

    this.homeRows.clear();
    final List<IOSpeakableImageButton> mButtons = new ArrayList<IOSpeakableImageButton>();
    List<IOSpeakableImageButton> configButtons = this.mBoard.getButtons();

    ViewGroup mainView = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.table_main_layout,
            null);/* w w  w .ja va 2s . c o m*/

    LinearLayout tableContainer = new LinearLayout(getActivity());
    LinearLayout.LayoutParams mainParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    tableContainer.setLayoutParams(mainParams);
    tableContainer.setOrientation(LinearLayout.VERTICAL);

    for (int i = 0; i < this.mBoard.getRows(); i++) {

        LinearLayout rowLayout = new LinearLayout(getActivity());
        LinearLayout.LayoutParams rowParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.f);
        rowLayout.setLayoutParams(rowParams);
        rowLayout.setOrientation(LinearLayout.HORIZONTAL);
        Random color = new Random();
        rowLayout.setBackgroundColor(Color.WHITE);
        tableContainer.addView(rowLayout);
        this.homeRows.add(rowLayout);
    }

    for (int j = 0; j < this.homeRows.size(); j++) {
        LinearLayout homeRow = this.homeRows.get(j);

        for (int i = 0; i < this.mBoard.getCols(); i++) {
            LinearLayout btnContainer = new LinearLayout(getActivity());
            LinearLayout.LayoutParams btnContainerParams = new LinearLayout.LayoutParams(0,
                    LinearLayout.LayoutParams.MATCH_PARENT, 1.f);
            btnContainer.setLayoutParams(btnContainerParams);
            btnContainer.setOrientation(LinearLayout.VERTICAL);
            btnContainer.setGravity(Gravity.CENTER);

            homeRow.addView(btnContainer);

            final IOSpeakableImageButton imgButton = (configButtons.size() > 0
                    && configButtons.size() > mButtons.size()) ? configButtons.get(mButtons.size())
                            : new IOSpeakableImageButton(getActivity());
            imgButton.setmContext(getActivity());
            imgButton.setShowBorder(IOConfiguration.getShowBorders());
            if (IOGlobalConfiguration.isEditing)
                imgButton.setImageDrawable(getResources().getDrawable(R.drawable.logo_org));
            else
                imgButton.setImageDrawable(null);
            imgButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            imgButton.setBackgroundColor(Color.TRANSPARENT);

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

                if (!new File(imgButton.getmImageFile()).exists()) {
                    if (mAlertDialog == null || !mAlertDialog.isShowing()) {
                        mAlertDialog = new AlertDialog.Builder(getActivity()).setCancelable(true)
                                .setTitle(getString(R.string.image_missing))
                                .setMessage(getString(R.string.image_missing_text))
                                .setNegativeButton(getString(R.string.continue_string), null).create();
                        mAlertDialog.show();
                    }

                    //download image

                    if (isExternalStorageReadable()) {

                        File baseFolder = new File(Environment.getExternalStorageDirectory() + "/"
                                + IOApplication.APPLICATION_FOLDER + "/pictograms");
                        Character pictoChar = imgButton.getmImageFile()
                                .charAt(imgButton.getmImageFile().lastIndexOf("/") + 1);
                        File pictoFolder = new File(baseFolder + "/" + pictoChar + "/");

                        if (isExternalStorageWritable()) {

                            pictoFolder.mkdirs();

                            //download it

                            AsyncHttpClient client = new AsyncHttpClient();
                            client.get(imgButton.getmUrl(),
                                    new FileAsyncHttpResponseHandler(new File(imgButton.getmImageFile())) {
                                        @Override
                                        public void onFailure(int statusCode, Header[] headers,
                                                Throwable throwable, File file) {
                                            Toast.makeText(getActivity(),
                                                    getString(R.string.download_error) + file.toString(),
                                                    Toast.LENGTH_LONG).show();
                                        }

                                        @Override
                                        public void onSuccess(int statusCode, Header[] headers,
                                                File downloadedFile) {

                                            if (new File(imgButton.getmImageFile()).exists()) {
                                                imgButton.setImageBitmap(
                                                        BitmapFactory.decodeFile(imgButton.getmImageFile()));
                                            } else {
                                                Toast.makeText(getActivity(),
                                                        getString(R.string.image_save_error),
                                                        Toast.LENGTH_SHORT).show();
                                            }
                                        }
                                    });
                        } else {

                            Toast.makeText(getActivity(), getString(R.string.image_save_error),
                                    Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_SHORT)
                                .show();
                    }

                } else
                    imgButton.setImageBitmap(BitmapFactory.decodeFile(imgButton.getmImageFile()));
            }

            ViewGroup parent = (ViewGroup) imgButton.getParent();

            if (parent != null)
                parent.removeAllViews();

            btnContainer.addView(imgButton);

            mButtons.add(imgButton);

            imgButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    int index = mButtons.indexOf(v);
                    if (mListener != null)
                        mListener.tapOnSpeakableButton(mButtons.get(index), mBoardLevel);
                }
            });
        }
    }

    this.mBoard.setButtons(mButtons.size() > configButtons.size() ? mButtons : configButtons);

    return tableContainer;
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingTabView.java

/**
 * Inits the view./*from   w  w  w  .  j av  a2s  .  com*/
 */
public void initView() {
    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new HorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    this.addView(mTabScrollView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    //View?
    mViewPager = new ESViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        ESLogUtil.e(ESSlidingTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingTabView.java

/**
 * Inits the view.//from   w w w  . j  a v a  2s  .c o m
 */
public void initView() {
    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new HorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    this.addView(mTabScrollView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    //View?
    mViewPager = new AbViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbSlidingTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }
}

From source file:com.java2s.intents4.IntentsDemo4Activity.java

void addRow(final LinearLayout layout, String label, String hintStr, boolean addRadioGroup) {
    LinearLayout.LayoutParams rowLayoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams editTextLayoutParams = new LinearLayout.LayoutParams(400,
            LinearLayout.LayoutParams.WRAP_CONTENT, 1);
    if (addRadioGroup) {
        editTextLayoutParams = new LinearLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
    }//from  ww  w  .j a  v  a  2  s  . co m
    LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0);

    LinearLayout row = new LinearLayout(this);
    row.setOrientation(LinearLayout.HORIZONTAL);
    row.setGravity(Gravity.CENTER_VERTICAL);

    TextView textView = new TextView(this);
    textView.setText(label);
    row.addView(textView);
    EditText editText = new EditText(this);
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    editText.setHint(hintStr);
    editText.setLayoutParams(editTextLayoutParams);
    if (!isFirstTime) {
        editText.requestFocus();
    }
    row.addView(editText);

    if (addRadioGroup) {
        LinearLayout groupLayout = new LinearLayout(this);
        groupLayout.setOrientation(LinearLayout.VERTICAL);
        groupLayout.setGravity(Gravity.CENTER_HORIZONTAL);

        RadioGroup group = new RadioGroup(this);
        group.setLayoutParams(new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT,
                RadioGroup.LayoutParams.WRAP_CONTENT));

        final Button patternButton = new Button(this);
        patternButton.setText(pathPatterns[0]);
        patternButton.setTextSize(8);
        patternButton.setLayoutParams(buttonLayoutParams);
        patternButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String patternButtonText = patternButton.getText().toString().trim();
                if (patternButtonText.equals(pathPatterns[0])) {
                    patternButton.setText(pathPatterns[1]);
                } else if (patternButtonText.equals(pathPatterns[1])) {
                    patternButton.setText(pathPatterns[2]);
                } else if (patternButtonText.equals(pathPatterns[2])) {
                    patternButton.setText(pathPatterns[0]);
                }
            }
        });
        groupLayout.addView(patternButton);
        row.addView(groupLayout);
    }
    Button button = new Button(this);
    button.setTextSize(10);
    button.setTypeface(null, Typeface.BOLD);
    button.setText("X");
    button.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    button.setLayoutParams(buttonLayoutParams);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            layout.removeView((LinearLayout) view.getParent());
        }
    });
    row.addView(button);

    row.setLayoutParams(rowLayoutParams);
    layout.addView(row);
}

From source file:com.loloof64.android.capturing_audio.MainActivity.java

public void purposeFileRenaming(final File externalStorageDir, final File tempAudioFile,
        final Calendar captureStartDate) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setTitle(R.string.renaming_temporary_file);

    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.HORIZONTAL);

    final TextView label = new TextView(this);
    label.setText(R.string.defining_file_name_label);
    layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    final EditText input = new EditText(this);
    input.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    input.setInputType(InputType.TYPE_CLASS_TEXT);

    layout.addView(label);//w w  w  .  j  a v  a 2  s. com
    layout.addView(input);
    dialogBuilder.setView(layout);

    dialogBuilder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String defaultNameRadix = new SimpleDateFormat(DEFAULT_FILE_NAME_FORMAT, Locale.getDefault())
                    .format(captureStartDate.getTime());
            String nameRadix = input.getText().toString();

            if (nameRadix.isEmpty()) {
                nameRadix = defaultNameRadix;
            }

            // Append a number to the name radix if necessary
            File testedFile = new File(externalStorageDir, String.format(FINAL_FILE_NAME_FORMAT, nameRadix));
            boolean fileNameAlreadyUsed = testedFile.exists();
            if (fileNameAlreadyUsed) {
                int number = 1;
                String chosenNameRadix;
                while (true) {
                    chosenNameRadix = String.format(Locale.getDefault(), "%s%d", nameRadix, number);
                    testedFile = new File(externalStorageDir,
                            String.format(FINAL_FILE_NAME_FORMAT, chosenNameRadix));
                    fileNameAlreadyUsed = testedFile.exists();
                    if (!fileNameAlreadyUsed)
                        break;
                    number++;
                }
                nameRadix = chosenNameRadix;
            }

            String fileName = String.format(FINAL_FILE_NAME_FORMAT, nameRadix);
            File newFile = new File(externalStorageDir, fileName);
            boolean renameSuccess = tempAudioFile.renameTo(newFile);

            if (renameSuccess) {
                Toast.makeText(MainActivity.this, R.string.renamed_file, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this, R.string.file_renaming_failure, Toast.LENGTH_SHORT).show();
            }
        }
    });

    dialogBuilder.show();
}

From source file:com.umeng.comm.ui.emoji.EmojiBorad.java

/**
 * </br>//from w w  w  .j  a v a 2s  .c o  m
 * 
 * @return
 */
private ViewGroup createPointLinearlayout() {
    LinearLayout pointContainerLayout = new LinearLayout(getContext());
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pointContainerLayout.setLayoutParams(params);
    pointContainerLayout.setOrientation(LinearLayout.HORIZONTAL);
    pointContainerLayout.setGravity(Gravity.CENTER);
    params.gravity = Gravity.CENTER;
    params.topMargin = DeviceUtils.dp2px(getContext(), 15);
    params.bottomMargin = DeviceUtils.dp2px(getContext(), 15);
    return pointContainerLayout;
}

From source file:com.pikachu.emoji.widget.EmojiView.java

/**
 * </br>/*from  w ww  .  ja  va 2 s  .co m*/
 * 
 * @return
 */
private ViewGroup createPointLinearlayout() {
    LinearLayout pointContainerLayout = new LinearLayout(getContext());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    pointContainerLayout.setLayoutParams(params);
    pointContainerLayout.setOrientation(LinearLayout.HORIZONTAL);
    pointContainerLayout.setGravity(Gravity.CENTER);
    params.gravity = Gravity.CENTER;
    params.topMargin = CommonUtils.dp2px(getContext(), 15);
    params.bottomMargin = CommonUtils.dp2px(getContext(), 15);
    return pointContainerLayout;
}

From source file:com.tony.selene.sliding.AbSlidingTabView.java

/**
 * Inits the view.//from   ww  w  .jav a 2  s. co m
 */
public void initView() {
    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new HorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    // mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    this.addView(mTabScrollView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    // View?
    mViewPager = new AbViewPager(context);
    // ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    // Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();

    // ?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbSlidingTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }
}

From source file:com.sonvp.tooltip.Tooltip.java

private Tooltip(Builder builder) {
    this.builder = builder;
    this.anchorView = builder.anchorView;
    this.gravity = builder.tooltipGravity;

    if (builder.dismissOutsideTouch) {

        rootView = (ViewGroup) anchorView.getRootView();
        overlay = new View(builder.context);
        overlay.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        //        overlay.setBackgroundColor(builder.context.getResources().getColor(android.R.color.holo_green_light));
        overlay.setOnTouchListener(this);
        rootView.addView(overlay);/*from  w w w  . j  a v a  2  s .  co m*/
    }

    // TODO container should NOT capture all events
    container = new LinearLayout(builder.context);
    container.setOnClickListener(this);

    int backgroundColor = builder.backgroundColor;

    viewTooltip = getViewTooltip(builder, backgroundColor);

    rectAnchorView = getRectView(anchorView);
    changeGravityToolTip();
    if (builder.arrowDrawable == null) {
        builder.arrowDrawable = new ArrowDrawable(backgroundColor, gravity);
    }

    arrow = new ImageView(builder.context);
    // TODO supports Gravity.NO_GRAVITY
    switch (gravity) {
    case Gravity.LEFT:
        container.setOrientation(LinearLayout.HORIZONTAL);
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        break;
    case Gravity.RIGHT:
        container.setOrientation(LinearLayout.HORIZONTAL);
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        break;
    case Gravity.TOP:
        container.setOrientation(LinearLayout.VERTICAL);
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        break;
    case Gravity.BOTTOM:
        container.setOrientation(LinearLayout.VERTICAL);
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        break;
    }

    popupWindow = new PopupWindow(container, ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setOnDismissListener(this);
    popupWindow.setClippingEnabled(false);
    popupWindow.setAnimationStyle(android.R.style.Animation);
    //        popupWindow.setBackgroundDrawable(builder.context.getResources().getDrawable(android.R.color.holo_blue_bright));

}