View 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 View setPadding method.

This code example shows how to use the following methods:getPaddingBottom, getPaddingLeft, getPaddingRight, setPadding
 
    /** 
     * Sets the header padding back to original size. 
     */ 
    private void resetHeaderPadding() { 
        mRefreshView.setPadding(
                mRefreshView.getPaddingLeft(),
                mRefreshOriginalTopPadding,
                mRefreshView.getPaddingRight(),
                mRefreshView.getPaddingBottom());
    } 
 
    /** 
     * Resets the header to the original state. 
     */ 
    private void resetHeader() { 
        if (mRefreshState != TAP_TO_REFRESH) {
            mRefreshState = TAP_TO_REFRESH;
 
            resetHeaderPadding(); 
8
CodeRank
This code example shows how to use the following methods:setLayoutParams, setPadding, setImageBitmap, setScaleType
This code example shows how to use the following methods:setLayoutParams, setPadding, setAdjustViewBounds, setImageResource, setScaleType
This code example shows how to use the following methods:setPadding, addView, setOrientation
8
CodeRank
This code example shows how to use the following methods:setLayoutParams, setPadding, setImageBitmap, setScaleType
	// Create the view for each user status 
	// [FIXME] Should be put as an XML file (possible?) 
	 
	private View makeUserStatusView(Context context, TwitterEntry entry) {
 
    	ImageView iv = new ImageView(context);
    	Bitmap photo = BitmapCache.getInstance().get(entry.getUser().getProfileImageURL());
 
    	iv.setImageBitmap(photo);
    	iv.setScaleType(ScaleType.CENTER);
    	iv.setPadding(0, 4, 4, 0);
    	iv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	 
    	TextView tv = new TextView(context);
    	tv.setText(entry.getUser().getName() + ": " + entry.getText());
    	tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	 
    	LinearLayout layout = new LinearLayout(context);
    	layout.setOrientation(LinearLayout.HORIZONTAL);
    	layout.setPadding(4, 2, 4, 2);
8
CodeRank
This code example shows how to use the following methods:setLayoutParams, setPadding, setMax, setProgress, setOnSeekBarChangeListener
		mValueText = new TextView(context);
		mValueText.setGravity(Gravity.RIGHT);
		mValueText.setPadding(20, 0, 20, 0);
		layout.addView(mValueText);
 
		SeekBar seekBar = new SeekBar(context);
		seekBar.setPadding(20, 0, 20, 20);
		seekBar.setLayoutParams(params);
		seekBar.setMax(1000);
		seekBar.setProgress((int)(Math.pow((float)(mValue - MIN) / (MAX - MIN), 0.25f) * 1000));
		seekBar.setOnSeekBarChangeListener(this);
		layout.addView(seekBar);
 
		updateText(); 
 
		builder.setView(layout);
	} 
 
	/** 
	 * Format seconds into a human-readable time description. 
8
CodeRank
This code example shows how to use the following methods:getPaddingBottom, getPaddingTop, setPadding
    public View onCreateView(LayoutInflater inflater,
            ViewGroup container, Bundle savedInstanceState) {
        final View view = super.onCreateView(inflater, container, savedInstanceState);
        final ListView list = (ListView) view.findViewById(android.R.id.list);
        // our container already takes care of the padding 
        int paddingTop = list.getPaddingTop();
        int paddingBottom = list.getPaddingBottom();
        list.setPadding(0, paddingTop, 0, paddingBottom);
        return view;
    } 
 
    @Override 
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        if (preference == mPrivacyGuardDefault) {
            boolean value = (Boolean) newValue;
            Settings.Secure.putInt(getContentResolver(),
                    Settings.Secure.PRIVACY_GUARD_DEFAULT, value ? 1 : 0);
            return true; 
        } 
        return false; 
8
CodeRank
This code example shows how to use the following methods:setBackgroundColor, setPadding, setImageBitmap
 
        v.setDrawingCacheEnabled(true);
        mFloatBitmap = Bitmap.createBitmap(v.getDrawingCache());
        v.setDrawingCacheEnabled(false);
 
        ImageView iv = new ImageView(mListView.getContext());
        iv.setBackgroundColor(mFloatBGColor);
        iv.setPadding(0, 0, 0, 0);
        iv.setImageBitmap(mFloatBitmap);
 
        return iv;
    } 
 
    /** 
     * Removes the Bitmap from the ImageView created in onCreateFloatView() and 
     * tells the system to recycle it. 
     */ 
    @Override 
    public void onDestroyFloatView(View floatView) {
        ((ImageView)floatView).setImageDrawable(null);
7
CodeRank
This code example shows how to use the following methods:setId, setPadding
				FrameLayout.LayoutParams.MATCH_PARENT));
	} 
 
	@Override 
	public void setContentView(final View view, final ViewGroup.LayoutParams params) {
		final ListView lv = new ListView(this);
		final Resources res = getResources();
		final float density = res.getDisplayMetrics().density;
		final int padding = (int) density * 16;
		lv.setId(android.R.id.list);
		lv.setPadding(padding, 0, padding, 0);
		super.setContentView(lv, params);
	} 
 
	public void setTheme() { 
		final SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
		final boolean is_dark_theme = preferences.getBoolean(PREFERENCE_KEY_DARK_THEME, false);
		final boolean solid_color_background = preferences.getBoolean(PREFERENCE_KEY_SOLID_COLOR_BACKGROUND, false);
		setTheme(is_dark_theme ? R.style.Theme_Twidere : R.style.Theme_Twidere_Light);
		if (solid_color_background) {
7
CodeRank
This code example shows how to use the following methods:getContext, setBackgroundDrawable, setPadding, setGravity
	 
	public static void setHeaderProfile(LinearLayout llProfileHeader) {
		if (llProfileHeader == null) {
			return; 
		} 
		Theme theme = ThemeUtil.createTheme(llProfileHeader.getContext());
		llProfileHeader.setBackgroundDrawable(theme.getDrawable("selector_bg_profile_header"));
		int padding8 = theme.dip2px(8);
		llProfileHeader.setPadding(padding8, padding8, padding8, padding8);
		llProfileHeader.setGravity(Gravity.CENTER);
	} 
} 
7
CodeRank

Related View setPadding Questions & Answers:

Other View setPadding Examples

53:			gridView.setColumnWidth(columnWidth);
54:			gridView.setStretchMode(GridView.NO_STRETCH);
55:			gridView.setPadding((int) padding, (int) padding, (int) padding,
56:					(int) padding);
57:			gridView.setHorizontalSpacing((int) padding);

Read More

25:	            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
26:	            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
27:	            imageView.setPadding(8, 8, 8, 8);
28:	        } else {
29:	            imageView = (ImageView) convertView;

Read More

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