Example usage for android.widget TextView setHeight

List of usage examples for android.widget TextView setHeight

Introduction

In this page you can find the example usage for android.widget TextView setHeight.

Prototype

@android.view.RemotableViewMethod
public void setHeight(int pixels) 

Source Link

Document

Sets the height of the TextView to be exactly pixels tall.

Usage

From source file:Main.java

protected static Bitmap creatCodeBitmap(String contents, int width, int height, Context context) {
    TextView tv = new TextView(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    tv.setLayoutParams(layoutParams);// www.ja  va2 s  .c o  m
    tv.setText(contents);
    tv.setHeight(height);
    tv.setGravity(Gravity.CENTER_HORIZONTAL);
    tv.setWidth(width);
    tv.setDrawingCacheEnabled(true);
    tv.setTextColor(Color.BLACK);
    tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());

    tv.buildDrawingCache();
    Bitmap bitmapCode = tv.getDrawingCache();
    return bitmapCode;
}

From source file:com.jeffreyawest.weblogic.monitor.charting.DefaultPieChart.java

protected final TableRow getRow(final Activity pActivity, int pColor, String pValue) {

    TableRow row = new TableRow(pActivity);
    row.setPadding(2, 2, 2, 2);/*w  w w . j  av a2 s.  c o  m*/

    pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size);

    TextView colorView = new TextView(pActivity);
    colorView.setBackgroundColor(pColor);
    colorView
            .setHeight((int) pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size));
    colorView.setText("   ");
    colorView.setWidth((int) pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size));
    row.addView(colorView);

    TextView text = new TextView(pActivity);
    text.setText(pValue);
    text.setPadding(2, 2, 2, 2);
    text.setTextSize(15);
    row.addView(text);

    return row;
}

From source file:at.flack.activity.NewSMSContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_contact);

    Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
    setSupportActionBar(toolbar);/*from w w w. java2 s .c  o  m*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    contactNameMap = new ContactNameMap(this);

    contactList = (ListView) this.findViewById(R.id.listview);

    TextView padding = new TextView(this);
    padding.setHeight(10);
    contactList.addHeaderView(padding);
    contactList.setHeaderDividersEnabled(false);
    contactList.addFooterView(padding, null, false);
    contactList.setFooterDividersEnabled(false);

    updateContacts();
    contactList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (contacts == null) {
                updateContacts();
            }
            openMessageActivity(NewSMSContactActivity.this, arg2 - 1);
        }

    });

}

From source file:org.akvo.caddisfly.ui.TypeListActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {

    final Activity activity = this;
    if (requestCode == PERMISSION_ALL) {
        // If request is cancelled, the result arrays are empty.
        boolean granted = false;
        for (int grantResult : grantResults) {
            if (grantResult != PERMISSION_GRANTED) {
                granted = false;//  ww  w  . ja  v a 2s  .  c  o m
                break;
            } else {
                granted = true;
            }
        }
        if (granted) {
            startCalibration();
        } else {
            String message = getString(R.string.cameraAndStoragePermissions);
            if (AppPreferences.useExternalCamera()) {
                message = getString(R.string.storagePermission);
            }
            Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
                    .setAction("SETTINGS", new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            ApiUtil.startInstalledAppDetailsActivity(activity);
                        }
                    });

            TypedValue typedValue = new TypedValue();
            getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);

            snackbar.setActionTextColor(typedValue.data);
            View snackView = snackbar.getView();
            TextView textView = (TextView) snackView.findViewById(android.support.design.R.id.snackbar_text);
            textView.setHeight(getResources().getDimensionPixelSize(R.dimen.snackBarHeight));
            textView.setLineSpacing(0, SNACK_BAR_LINE_SPACING);
            textView.setTextColor(Color.WHITE);
            snackbar.show();
        }
    }
}

From source file:com.dedipower.portal.android.CDNLanding.java

public void UpdateErrorMessage(String MessageText) {
    TextView ErrorMessage = (TextView) findViewById(R.id.ErrorMessageText);
    if (MessageText.length() == 0) {
        ErrorMessage.setHeight(0);
    } else {/*w ww .jav a  2  s.  co m*/
        ErrorMessage.setHeight(24);
        ErrorMessage.setTextColor(-65536);
        ErrorMessage.setText(MessageText);
    }
}

From source file:at.flack.activity.NewFbContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_contact);

    Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
    setSupportActionBar(toolbar);//from  ww w.j  av a  2  s .c  o m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    contactList = (ListView) this.findViewById(R.id.listview);
    progressbar = this.findViewById(R.id.load_screen);
    searchBig = this.findViewById(R.id.search_big);
    searchBig.setVisibility(View.VISIBLE);
    TextView padding = new TextView(this);
    padding.setHeight(10);
    contactList.addHeaderView(padding);
    contactList.setHeaderDividersEnabled(false);
    contactList.addFooterView(padding, null, false);
    contactList.setFooterDividersEnabled(false);

    updateContacts(null);
    contactList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (contacts == null) {
                updateContacts(null);
            }
            openMessageActivity(NewFbContactActivity.this, arg2 - 1);
        }

    });

    try {
        fb_img = ProfilePictureCache.getInstance(this);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:at.flack.SMSMainActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_sms_main, container, false);

    contactNameMap = new ContactNameMap(getActivity());

    contactList = (ListView) rootView.findViewById(R.id.listviewsms);

    TextView padding = new TextView(getActivity());
    padding.setHeight(10);
    contactList.addHeaderView(padding);/*from  www  .  j ava2 s  . co  m*/
    contactList.setHeaderDividersEnabled(false);
    contactList.addFooterView(padding, null, false);
    contactList.setFooterDividersEnabled(false);

    swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
    swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (getActivity() instanceof MainActivity)
                ((MainActivity) getActivity()).updateSMSContacts();
        }
    });
    contactList.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0
                    : contactList.getChildAt(0).getTop();
            swipe.setEnabled(topRowVerticalPosition >= 0);
        }
    });

    progressbar = rootView.findViewById(R.id.load_screen);
    if (MainActivity.getContacts() == null)
        progressbar.setVisibility(View.VISIBLE);

    updateContacts((MainActivity) getActivity());
    contactList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (MainActivity.getListItems() == null) {
                updateContacts((MainActivity) getActivity());
            }
            openMessageActivity(getActivity(), arg2 - 1);
        }

    });
    FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    fab.attachToListView(contactList);
    fab.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent qr = new Intent(getActivity(), NewSMSContactActivity.class);
            startActivityForResult(qr, 1);
        }
    });

    setRetainInstance(true);

    return rootView;
}

From source file:com.dedipower.portal.android.ViewTicket.java

public void UpdateErrorMessage(String MessageText) {
    TextView ErrorMessage = (TextView) findViewById(R.id.ErrorMessageText);
    if (MessageText.length() == 0) {
        ErrorMessage.setHeight(0);
    } else {/*from w  w  w .ja v  a  2 s.c o  m*/

        ErrorMessage.setTextColor(-65536);
        ErrorMessage.setText(MessageText);
    }
}

From source file:at.flack.MailOutActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_mail_main, container, false);

    loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false));
    contactList = (ListView) rootView.findViewById(R.id.listview);
    TextView padding = new TextView(getActivity());
    padding.setHeight(10);
    contactList.addHeaderView(padding);/*ww w.j a  v  a 2s  . com*/
    contactList.setHeaderDividersEnabled(false);

    contactList.setFooterDividersEnabled(false);
    progressbar = rootView.findViewById(R.id.load_screen);
    FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    fab.attachToListView(contactList);

    fab.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent newMail = new Intent(getActivity(), NewMailActivity.class);
            getActivity().startActivity(newMail);
        }
    });

    progressbar = rootView.findViewById(R.id.load_screen);
    if (mailOutList == null)
        progressbar.setVisibility(View.VISIBLE);
    updateContactList(((MainActivity) this.getActivity()));

    swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
    swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (getActivity() instanceof MainActivity) {
                updateContactList(((MainActivity) getActivity()));
            }

        }
    });
    contactList.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0
                    : contactList.getChildAt(0).getTop();
            swipe.setEnabled(topRowVerticalPosition >= 0);
        }
    });

    contactList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (mailOutList == null) {
                updateContactList((MainActivity) getActivity());
            }
            openMessageActivity(getActivity(), arg2 - 1);
        }

    });
    setRetainInstance(true);
    return rootView;

}

From source file:org.akvo.caddisfly.sensor.colorimetry.strip.ui.BrandInfoActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {

    final Activity activity = this;
    if (requestCode == PERMISSION_ALL) {
        // If request is cancelled, the result arrays are empty.
        boolean granted = false;
        for (int grantResult : grantResults) {
            if (grantResult != PERMISSION_GRANTED) {
                granted = false;//from w  w w.  ja v a 2 s.c  o m
                break;
            } else {
                granted = true;
            }
        }
        if (granted) {
            startCamera();
        } else {
            Snackbar snackbar = Snackbar.make(coordinatorLayout,
                    getString(R.string.cameraAndStoragePermissions), Snackbar.LENGTH_LONG)
                    .setAction("SETTINGS", new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            ApiUtil.startInstalledAppDetailsActivity(activity);
                        }
                    });

            TypedValue typedValue = new TypedValue();
            getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);

            snackbar.setActionTextColor(typedValue.data);
            View snackView = snackbar.getView();
            TextView textView = (TextView) snackView.findViewById(android.support.design.R.id.snackbar_text);
            textView.setHeight(getResources().getDimensionPixelSize(R.dimen.snackBarHeight));
            textView.setLineSpacing(0, SNACK_BAR_LINE_SPACING);
            textView.setTextColor(Color.WHITE);
            snackbar.show();
        }
    }
}