List of usage examples for android.view View setPadding
public void setPadding(int left, int top, int right, int bottom)
From source file:com.h6ah4i.android.example.openslmediaplayer.app.NavigationDrawerFragment.java
public void setSystemBarsOffset(int statusBarOffset, int navBarOffset) { if (mModeSelectListView != null) { View v = mModeSelectListView; v.setPadding(ViewCompat.getPaddingStart(v), statusBarOffset, ViewCompat.getPaddingEnd(v), v.getPaddingBottom());// w w w . j av a 2s. co m } if (mPageSelectListView != null) { View v = mPageSelectListView; v.setPadding(ViewCompat.getPaddingStart(v), v.getPaddingTop(), ViewCompat.getPaddingEnd(v), navBarOffset); } }
From source file:com.landenlabs.all_devtool.DevFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (GlobalInfo.s_globalInfo.isLockedOrientation) { getActivity().setRequestedOrientation(GlobalInfo.s_globalInfo.lockedOrientation); }// w w w .j av a 2s. com cacheFragment(); // this.setRetainInstance(true); if (GlobalInfo.s_globalInfo.haveActionBarOverlay) { // ViewPager.LayoutParams viewParams = (ViewPager.LayoutParams)view.getLayoutParams(); view.setPadding(0, GlobalInfo.s_globalInfo.actionBarHeight * 2, 0, 0); } }
From source file:com.near.chimerarevo.fragments.AboutContainerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about_container_layout, container, false); boolean isLandscapeLarge = false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true;/* w w w .j a v a 2s. c om*/ } else isLandscapeLarge = false; if (!isLandscapeLarge) v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0); ViewPager pager = (ViewPager) v.findViewById(R.id.view_pager); pager.setAdapter(new AboutPagerAdapter()); return v; }
From source file:com.eggwall.SoundSleep.SleepActivity.java
/** * Moves the icons to some random location. *//*from www. ja v a2s. c o m*/ private void changeIconLocation() { populateTopLevelDimen(); setGlobalScreenSettings(); if (cloudSize == null || noteSize == null) { return; } final double locationX = Math.random(); // The top half of the screen is for the note. final int noteY = 0; // The bottom half of the screen is for white noise. final int cloudY = mHeight - cloudSize.mSecond; // The cloud and the note mirror each other on opposite sides to // increase visual separation. final int cloudX = (int) (locationX * (mWidth - cloudSize.mFirst)); final float newCloudAlpha = (float) (.35 - (mAlphaDecrement / 100.0)); final float newNoteAlpha = (float) (.50 - (mAlphaDecrement / 100.0)); final int noteX = (int) ((1 - locationX) * (mWidth - noteSize.mFirst)); mAlphaDecrement += 5; if (mAlphaDecrement > 20) { mAlphaDecrement = 20; } final View cloud = findViewById(R.id.cloud); final View note = findViewById(R.id.note); if (SDK >= 11) { cloud.setY(cloudY); cloud.animate().x(cloudX).alpha(newCloudAlpha); note.setY(noteY); note.animate().x(noteX).alpha(newNoteAlpha); } else { cloud.setPadding(cloudX, cloudY, 0, 0); note.setPadding(noteX, noteY, 0, 0); } }
From source file:com.near.chimerarevo.fragments.WebFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.webview_layout, container, false); boolean isLandscapeLarge = false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true;/*from ww w . jav a2 s . c om*/ } else isLandscapeLarge = false; if (!isLandscapeLarge) v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0); mWebView = (WebView) v.findViewById(R.id.webview); mProgressContainer = v.findViewById(R.id.progressContainer); mWebContainer = v.findViewById(R.id.webViewContainer); return v; }
From source file:org.telegram.ui.Adapters.ContactsAdapter.java
@SuppressLint("NewApi") @Override//from www . j a va 2 s.c o m public View getItemView(int section, int position, View convertView, ViewGroup parent) { int type = getItemViewType(section, position); if (type == 4) { if (convertView == null) { convertView = new DividerCell(mContext); convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 28 : 72), 0, AndroidUtilities.dp(LocaleController.isRTL ? 72 : 28), 0); convertView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.chat_list_background)); convertView.setElevation(AndroidUtilities.dp(2)); } } else if (type == 3) { if (convertView == null) { convertView = new GreySectionCell(mContext); ((GreySectionCell) convertView) .setText(LocaleController.getString("Contacts", R.string.Contacts).toUpperCase()); //convertView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.s)); convertView.setElevation(AndroidUtilities.dp(2)); } } else if (type == 2) { if (convertView == null) { convertView = new TextCell(mContext); convertView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.chat_list_background)); } TextCell actionCell = (TextCell) convertView; if (needPhonebook) { actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite); } else if (isAdmin) { actionCell.setTextAndIcon( LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.menu_invite); } else { if (position == 0) { actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup); } else if (position == 1) { actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret); } else if (position == 2) { actionCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast); } } } else if (type == 1) { if (convertView == null) { convertView = new TextCell(mContext); convertView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.chat_list_background)); } ContactsController.Contact contact = ContactsController.getInstance().phoneBookContacts.get(position); TextCell textCell = (TextCell) convertView; if (contact.first_name != null && contact.last_name != null) { textCell.setText(contact.first_name + " " + contact.last_name); } else if (contact.first_name != null && contact.last_name == null) { textCell.setText(contact.first_name); } else { textCell.setText(contact.last_name); } } else if (type == 0) { if (convertView == null) { convertView = new UserCell(mContext, 58, 1, false); convertView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.chat_list_background)); ((UserCell) convertView).setStatusColors(0xffa8a8a8, 0xff3b84c0); } HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance().usersMutualSectionsDict : ContactsController.getInstance().usersSectionsDict; ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance().sortedUsersMutualSectionsArray : ContactsController.getInstance().sortedUsersSectionsArray; ArrayList<TLRPC.TL_contact> arr = usersSectionsDict .get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1))); TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id); ((UserCell) convertView).setData(user, null, null, 0); if (checkedMap != null) { ((UserCell) convertView).setChecked(checkedMap.containsKey(user.id), !scrolling); } if (ignoreUsers != null) { if (ignoreUsers.containsKey(user.id)) { convertView.setAlpha(0.5f); } else { convertView.setAlpha(1.0f); } } } if (type != 4) { if (convertView instanceof ForegroundFrameLayout) { ((ForegroundFrameLayout) convertView).setForeground(R.drawable.list_selector); } } return convertView; }
From source file:com.near.chimerarevo.fragments.FavoritesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.recyclerview_layout, container, false); boolean isLandscapeLarge = false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true;/*from ww w .j a v a 2 s. co m*/ } else isLandscapeLarge = false; if (!isLandscapeLarge) v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0); mListView = (RecyclerView) v.findViewById(R.id.cardList); mProgressContainer = v.findViewById(R.id.progressContainer); mListContainer = v.findViewById(R.id.listContainer); mEmptyText = v.findViewById(android.R.id.empty); ((TextView) v.findViewById(android.R.id.empty)).setText(R.string.text_nofavorites); return v; }
From source file:com.github.johnpersano.supertoasts.demo.views.TabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);/*from ww w . j a v a 2 s. com*/ tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.cardvlaue.sys.redenvelope.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);/* w w w . j av a 2 s . c o m*/ tab.setOnClickListener(v -> pager.setCurrentItem(position)); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.qs.qswlw.view.Mypager.UltraViewPagerView.java
protected void onMeasurePage(int widthMeasureSpec, int heightMeasureSpec) { Log.d("TEST", "onMeasurePage" + getCurrentItem()); View child = pagerAdapter.getViewAtPosition(getCurrentItem()); if (child == null) { child = getChildAt(0);/*from w w w . ja va 2 s . c om*/ } if (child == null) { return; } for (int i = 0; i < getChildCount(); i++) { View view = getChildAt(i); if ((view.getPaddingLeft() != itemMarginLeft || view.getPaddingTop() != itemMarginTop || view.getPaddingRight() != itemMarginRight || view.getPaddingBottom() != itemMarginBottom)) { view.setPadding(itemMarginLeft, itemMarginTop, itemMarginRight, itemMarginBottom); } } ViewGroup.LayoutParams lp = child.getLayoutParams(); final int childWidthSpec = getChildMeasureSpec(widthMeasureSpec, 0, lp.width); final int childHeightSpec = getChildMeasureSpec(heightMeasureSpec, 0, lp.height); int childWidth = (int) ((MeasureSpec.getSize(childWidthSpec) - getPaddingLeft() - getPaddingRight()) * pagerAdapter.getPageWidth(getCurrentItem())); int childHeight = MeasureSpec.getSize(childHeightSpec) - getPaddingTop() - getPaddingBottom(); if (!needsMeasurePage || childWidth == 0 && childHeight == 0) { return; } if (!Double.isNaN(itemRatio)) { int itemHeight = (int) (childWidth / itemRatio); for (int i = 0, childCount = getChildCount(); i < childCount; i++) { View view = getChildAt(i); view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(itemHeight, MeasureSpec.EXACTLY)); } } else { for (int i = 0, childCount = getChildCount(); i < childCount; i++) { View view = getChildAt(i); if (pagerAdapter.getPageWidth(getCurrentItem()) != 1) { view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); } else { view.measure(childWidthSpec, childHeightSpec); } } } final boolean isHorizontalScroll = scrollMode == UltraViewPager.ScrollMode.HORIZONTAL; childWidth = itemMarginLeft + child.getMeasuredWidth() + itemMarginRight; childHeight = itemMarginTop + child.getMeasuredHeight() + itemMarginBottom; if (!Float.isNaN(ratio)) { heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (getMeasuredWidth() / ratio), MeasureSpec.EXACTLY); setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); for (int i = 0, childCount = getChildCount(); i < childCount; i++) { View view = getChildAt(i); view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), heightMeasureSpec); } } else { if (autoMeasureHeight) { if (isHorizontalScroll) { constrainLength = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY); setMeasuredDimension(getMeasuredWidth(), childHeight); } else { constrainLength = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY); setMeasuredDimension(childWidth, getMeasuredHeight()); } needsMeasurePage = childHeight == itemMarginTop + itemMarginBottom; } } if (!pagerAdapter.isEnableMultiScr()) { return; } int pageLength = isHorizontalScroll ? getMeasuredWidth() : getMeasuredHeight(); final int childLength = isHorizontalScroll ? child.getMeasuredWidth() : child.getMeasuredHeight(); // Check that the measurement was successful if (childLength > 0) { needsMeasurePage = false; int difference = pageLength - childLength; if (getPageMargin() == 0) { setPageMargin(-difference); } int offscreen = (int) Math.ceil((float) pageLength / (float) childLength) + 1; setOffscreenPageLimit(offscreen); requestLayout(); } }