Example usage for android.view Gravity CENTER

List of usage examples for android.view Gravity CENTER

Introduction

In this page you can find the example usage for android.view Gravity CENTER.

Prototype

int CENTER

To view the source code for android.view Gravity CENTER.

Click Source Link

Document

Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.

Usage

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * DOUBLE IMAGE ROW//from w  w w .j a  va 2  s . co m
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getDoubleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.3f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value_params);

    LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46,
            0.35f);
    ImageView img1 = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value1"));
    img1.setImageResource(context.getResources().getIdentifier(path, null, null));
    img1.setPadding(0, 3, 0, 3);
    container_layout.addView(img1, value_one_params);

    LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46,
            0.35f);
    ImageView img2 = new ImageView(context);
    path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value2"));
    img2.setImageResource(context.getResources().getIdentifier(path, null, null));
    img2.setPadding(0, 3, 0, 3);
    container_layout.addView(img2, value_two_params);

    linear.addView(container_layout);

    return linear;
}

From source file:com.anjuke.library.uicomponent.slidingtab.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//from w  w  w .ja  v a2s  .  c  o m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    tabsContainer.addView(tab);
}

From source file:com.astuetz.pagersslidingtabstrip.PagerSlidingTabStrip.java

/** Icon is added here.*/
private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//from w  ww .ja  v  a  2 s.  c o  m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    addTab(position, tab);
}

From source file:com.altitudelabs.swiftcart.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);/*from   ww  w .  j av a 2s .com*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextSize(getResources().getDimension(R.dimen.pager_tab_strip_slider_textsize));
    tab.setTextColor(getResources().getColor(R.color.pager_tab_strip_text_color));

    addTab(position, tab);
}

From source file:com.abcs.huaqiaobang.tljr.news.tabs.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);/*from ww  w .  ja v a  2  s  . c om*/
    tab.setGravity(Gravity.CENTER);
    //      DisplayMetrics dm = getResources().getDisplayMetrics();
    //      tab.setWidth(dm.widthPixels*2/3);
    tab.setSingleLine();

    addTab(position, tab);
}

From source file:PagerSlidingTab.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);/*  ww  w .  jav  a2 s .  com*/
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1));

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:at.wada811.android.dialogfragments.sample.alertdialogfragment.AlertDialogFragmentExamplesFragment.java

@Override
public DialogFragmentCallback getDialogFragmentCallback() {
    return new SimpleDialogFragmentCallback() {
        @Override/*  w w  w  .  ja  v a  2  s  . co  m*/
        public void onShow(DialogFragmentInterface dialog) {
            String text = "onShow";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onCancel(DialogFragmentInterface dialog) {
            String text = "onCancel";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onDismiss(DialogFragmentInterface dialog) {
            String text = "onDismiss";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onClickPositive(DialogFragmentInterface dialog) {
            String text = "onClickPositive";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onClickNeutral(DialogFragmentInterface dialog) {
            String text = "onClickNeutral";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onClickNegative(DialogFragmentInterface dialog) {
            String text = "onClickNegative";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public boolean onKey(DialogFragmentInterface dialog, int keyCode, KeyEvent event) {
            String text = "onKey[keyCode: " + keyCode + ", KeyEvent: " + event + "]";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
            return false;
        }

        @Override
        public void onItemClick(DialogFragmentInterface dialog, int position) {
            Bundle extra = dialog.getExtra();
            String[] items = extra.getStringArray("items");
            String text = "onItemClick[position: " + position + ", item: " + items[position] + "]";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public ListAdapter getAdapter(DialogFragmentInterface dialog) {
            String[] items = new String[] { AlertDialog.class.getSimpleName(),
                    CharacterPickerDialog.class.getSimpleName(), ProgressDialog.class.getSimpleName(),
                    DatePickerDialog.class.getSimpleName(), TimePickerDialog.class.getSimpleName(), };
            Bundle extra = new Bundle();
            extra.putStringArray("items", items);
            dialog.setExtra(extra);
            return new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, items);
        }

        @Override
        public void onSingleChoiceClick(DialogFragmentInterface dialog, int position) {
            Bundle extra = dialog.getExtra();
            String[] items = extra.getStringArray("items");
            String text = "onItemClick[position: " + position + ", item: " + items[position] + "]";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onMultiChoiceClick(DialogFragmentInterface dialog, int position, boolean isChecked) {
            Bundle extra = dialog.getExtra();
            String[] items = extra.getStringArray("items");
            String text = "onItemClick[position: " + position + ", item: " + items[position] + ", isChecked: "
                    + isChecked + "]";
            Log.v(dialog.getTag(), text);
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }

        @Override
        public View getCustomTitle(DialogFragmentInterface dialog) {
            TextView titleView = new TextView(getActivity());
            titleView.setText(dialog.getTag());
            titleView.setPadding(0, 24, 0, 24);
            titleView.setGravity(Gravity.CENTER);
            titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
            return titleView;
        }

        @Override
        public View getView(DialogFragmentInterface dialog) {
            ImageView imageView = new ImageView(getActivity());
            imageView.setImageResource(R.drawable.ic_launcher);
            imageView.setPadding(0, 24, 0, 24);
            return imageView;
        }
    };
}

From source file:ab.util.AbDialogUtil.java

/**
 * /*  w  w w . j a v a 2s  .com*/
 * ???().
 * 
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @param onCancelListener
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, DialogInterface.OnCancelListener onCancelListener) {
    return showDialog(view, animEnter, animExit, animPopEnter, animPopExit, Gravity.CENTER, onCancelListener);
}

From source file:cn.com.incito.driver.UI.detailDialog.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);/*from ww  w .j av  a 2 s.  co  m*/
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1));
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:asia.utopia.musicoff.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//from w  w  w  .  j  a v a2 s. c  o m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}