TextView setPadding - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView setPadding method.

This code example shows how to use the following methods:setPadding, setText, setTextColor, setTextSize
     
    TextView textView = (TextView)row.findViewById(android.R.id.text1);
    float scale = activity.getResources().getDisplayMetrics().density;
    boolean leftPadding = (parent.getTag().equals("right"));
    boolean topPadding = (position == 0);
    textView.setPadding((int)(20 * scale) * (leftPadding ? 2 : 1), (int)(20 * scale) * (!leftPadding && topPadding ? 1 : 0), (int)(20 * scale), 0);
    textView.setText(item);
    textView.setTextColor(Color.BLACK);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
     
    return row;
  } 
 
  private View getWebView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    if ((row == null) || (row.findViewById(1337) == null)) {
      RelativeLayout layout = new RelativeLayout(activity);
      layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT));
      row = layout;
       
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setId, setVisibility, setGravity, setPadding, setText
This code example shows how to use the following methods:setLayoutParams, setCompoundDrawablesWithIntrinsicBounds, setGravity, setPadding, setText
			} catch (NameNotFoundException e) {
				return 0; 
			} 
        } 
        public TextView getGenericView() {
            TextView textView = new TextView(ActivityPickerActivity.this);
            textView.setLayoutParams(lpGroup);
            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
            textView.setPadding(leftPadding, 0, 0, 0);
            return textView;
        } 
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            ActivityInfo activity=getChild(groupPosition, childPosition);
            if(activity!=null){
	            String name=activity.name.replace(activity.packageName, "");
	        	textView.setText(activity.loadLabel(mPackageManager)+"("+name+")");
	        	textView.setLayoutParams(lpChild);
            } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setGravity, setPadding, setText, setTextSize
		playerText.setText(score.getPlayer());
		playerText.setGravity(Gravity.LEFT);
		playerText.setPadding(10, 10, 10, 10);
		playerText.setTextSize(16);
 
		TextView scoreText = new TextView(parent.getContext());
		scoreText.setText(String.valueOf(score.getScore()));
		scoreText.setGravity(Gravity.RIGHT);
		scoreText.setPadding(10, 10, 10, 10);
		scoreText.setTextSize(16);
 
		layout.addView(playerText);
		layout.addView(scoreText);
 
		return layout;
	} 
 
	public List<HighScore> getScores() {
		return scores;
	} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setGravity, setPadding, setText
        public TextView getGenericView() {
            // Layout parameters for the ExpandableListView 
            AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, 64);
 
            TextView textView = new TextView(ExpandableList1.this);
            textView.setLayoutParams(lp);
            // Center the text vertically 
            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
            // Set the text starting position 
            textView.setPadding(36, 0, 0, 0);
            return textView;
        } 
         
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            textView.setText(getChild(groupPosition, childPosition).toString());
            return textView;
        } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLinkTextColor, setMovementMethod, setPadding, setText, setTextColor
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		 
		setTitle("Information");
		 
		TextView tv = new TextView(this);
		tv.setTextColor(0xffffffff);
		tv.setLinkTextColor(0xffa3b8fe);
		int p = AndroidUtils.dipToPixel(this, 10);
		tv.setPadding(p, p, p, p);
		tv.setText(Html.fromHtml(getIntent().getStringExtra("info")));
		tv.setMovementMethod(LinkMovementMethod.getInstance());
		 
		ScrollView sv = new ScrollView(this);
		sv.addView(tv);
		 
		setContentView(sv);
	} 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setGravity, setMaxWidth, setMinWidth, setPadding, setText
	public void removeItemAt(int pos) {
		this.messages.remove(pos);
	} 
 
	public View getView(int pos, View convertView, ViewGroup parent) {
		TextView messageText = new TextView(parent.getContext());
		messageText.setText(this.getMessageText(pos));
		messageText.setGravity(Gravity.LEFT);
		messageText.setPadding(10, 10, 10, 10);
		messageText.setMaxWidth(200);
		messageText.setMinWidth(200);
		messageText.setTextSize(16);
 
		return messageText;
	} 
 
	private String extractMessageFromJsonObject(String json) {
		try { 
			ObjectMapper mapper = new ObjectMapper();
			Map<String, Object> jsonDic = mapper.readValue(json,
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getContext, setCompoundDrawablePadding, setCompoundDrawablesWithIntrinsicBounds, setPadding, setText
 
        return false; 
    } 
 
    public static void applyButtonDef(@Nonnull Button button, @Nonnull ButtonDef buttonDef) {
        button.setText(buttonDef.getText());
 
        final Integer drawableResId = buttonDef.getDrawableResId();
        if ( drawableResId != null ) {
            button.setPadding(0, 0, 0, 0);
 
            final Drawable drawable = button.getContext().getResources().getDrawable(drawableResId);
            button.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
            button.setCompoundDrawablePadding(0);
        } 
 
        applyViewDef(button, buttonDef);
    } 
 
    public static void applyButtonDef(@Nonnull ImageButton imageButton, @Nonnull ButtonDef buttonDef) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setOnClickListener, setChecked, setGravity, setPadding
 
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
            AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                    ViewGroup.LayoutParams.FILL_PARENT, 64);
 
            CheckBox checkBox = new CheckBox(Plugins_View.this);
            checkBox.setLayoutParams(lp);
            // Center the text vertically 
            checkBox.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER);
            // Set the text starting position 
            checkBox.setOnClickListener(new OnClickListener(){
            	public void onClick(View v){
                    if (((CheckBox) v).isChecked()) {
                    	SharedPreferences settings = getSharedPreferences("Munin_Node", 0);
                        SharedPreferences.Editor editor = settings.edit();
                        editor.putBoolean(((CheckBox) v).getText().toString(), true);
                        editor.commit();
                    } else { 
                    	SharedPreferences settings = getSharedPreferences("Munin_Node", 0);
                        SharedPreferences.Editor editor = settings.edit();

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setClickable, setAutoLinkMask, setPadding, setText, setTextSize
        return dialog.create();
    } 
     
    public static AlertDialog createInfoDialog(
            final Context context, int title, CharSequence content) {
        TextView tv = new TextView(context);
        tv.setTextSize(18);
        tv.setAutoLinkMask(Linkify.WEB_URLS);
        tv.setText(content);
        tv.setClickable(false);
        tv.setPadding(15, 0, 0, 0);
        return createInfoDialog(context, title, tv);
    } 
     
    public static AlertDialog createConfirmDialog(Context context, 
            DialogInterface.OnClickListener onClickListener, 
            CharSequence title, CharSequence content) {
        return createConfirmDialog(context, onClickListener, null, title, content);
    } 
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related TextView setPadding Questions & Answers:

setPadding Method Overview
Sets the padding.
See Code Examples for other Android TextView Methods: