List of usage examples for android.view View getPaddingBottom
public int getPaddingBottom()
From source file:mn.today.TheHubActivity.java
/** * Displays a popup window prompting the user to * * Confirm the changes to the name, saving the new name to file and updating the UI. * * Cancel the changes, returning the user back to the original state before editing * * @param newName new name to be used//from w ww. jav a 2 s .c o m * @param cardPosition position of cardview in adapter * @param cardViewClicked the cardview view object clicked * @param switcher the viewSwitcher object used to rename */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) private void showEditPopupWindow(final EditText newName, View cardViewClicked, final ViewSwitcher switcher, final int cardPosition) { LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_window_editing, null); LinearLayout viewGroup = (LinearLayout) layout.findViewById(R.id.popup_editing); // Creating the PopupWindow final PopupWindow popupEditing = new PopupWindow(layout, RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT); int dividerMargin = viewGroup.getDividerPadding(); // Top bottom int popupPadding = layout.getPaddingBottom(); int popupDisplayHeight = -(cardViewClicked.getHeight() - dividerMargin - popupPadding); // Prevents border from appearing outside popupwindow popupEditing.setBackgroundDrawable(new ColorDrawable()); popupEditing.setFocusable(false); // Getting a reference to Close button, and close the popup when clicked. ImageView confirmEdit = (ImageView) layout.findViewById(R.id.popup_confirm_item_changes); confirmEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ToDay toChange = rvContent.get(cardPosition); if (newName.getText().toString().equals("")) { // Need to optimize this so that the dialog does NOT disappear and just display toast Toast.makeText(TheHubActivity.this, "?? !", Toast.LENGTH_LONG).show(); } else { toChange.setName(newName.getText().toString()); manager.overwrite(toChange.getUuid(), toChange); adapter.notifyDataSetChanged(); switcher.showNext(); menuState = AppConstants.MENU_ITEMS_NATIVE; invalidateOptionsMenu(); popupEditing.dismiss(); newName.clearFocus(); } } }); ImageView cancelEdit = (ImageView) layout.findViewById(R.id.popup_cancel_item_changes); cancelEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switcher.showNext(); menuState = AppConstants.MENU_ITEMS_NATIVE; invalidateOptionsMenu(); popupEditing.dismiss(); } }); // Displaying the popup at the specified location, + offsets. popupEditing.showAsDropDown(cardViewClicked, cardViewClicked.getMeasuredWidth(), popupDisplayHeight, Gravity.TOP); editingPopup = popupEditing; }
From source file:mn.today.TheHubActivity.java
/** * Generates a Popup Menu with Two Actions Edit and Delete. * * Deleting the Flow removes the single card from the UI and also notifiers the AppDataManager to * delete from file/* w w w . j av a 2 s . co m*/ * * Editing launches a renaming process * * @param longClickedFlow Flow represented by cardview longclicked * @param cardPosition position of cardview in adapter * @param cardViewClicked the cardview view object clicked * @return */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) private boolean showLongClickPopUpMenu(final ToDay longClickedFlow, final int cardPosition, final View cardViewClicked) { LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_window_longclick, null); LinearLayout viewGroup = (LinearLayout) layout.findViewById(R.id.popup_longclick); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(layout, RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT); int dividerMargin = viewGroup.getDividerPadding(); // Top bottom int popupPadding = layout.getPaddingBottom(); int popupDisplayHeight = -(cardViewClicked.getHeight() - dividerMargin - popupPadding); // Prevents border popup.setBackgroundDrawable(new ColorDrawable()); popup.setFocusable(true); // Getting a reference to Close button, and close the popup when clicked. ImageView delete = (ImageView) layout.findViewById(R.id.popup_delete_item); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* Deletes current Flow from file and UI */ rvContent.remove(cardPosition); manager.delete(longClickedFlow.getUuid()); adapter.notifyItemRemoved(cardPosition); adapter.notifyItemRangeChanged(cardPosition, adapter.getItemCount()); popup.dismiss(); Snackbar bar = Snackbar.make(cardViewClicked, R.string.snackbar_hub_msg, Snackbar.LENGTH_LONG) .setAction("!!!", new View.OnClickListener() { @Override public void onClick(View v) { rvContent.add(cardPosition, longClickedFlow); manager.save(longClickedFlow.getUuid(), longClickedFlow); adapter.notifyItemInserted(cardPosition); } }); bar.show(); } }); ImageView edit = (ImageView) layout.findViewById(R.id.popup_edit_item); edit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popup.dismiss(); renameFlow(cardPosition, cardViewClicked); } }); // Displaying the popup at the specified location, + offsets. popup.showAsDropDown(cardViewClicked, cardViewClicked.getMeasuredWidth(), popupDisplayHeight, Gravity.TOP); longClickPopup = popup; return true; }
From source file:com.vnidens.clickableedittext.ClickableEditTextHelper.java
private boolean isTouchInside(@NonNull View v, int xTouch, int yTouch, int drawablePosition) { Rect iconRect;// w w w. j av a2 s. c om int viewPaddingStart = ViewCompat.getPaddingStart(v); int viewPaddingEnd = ViewCompat.getPaddingEnd(v); int ltDirection = ViewCompat.getLayoutDirection(v); switch (drawablePosition) { case DRAWABLE_POSITION_START: if (startButtonDrawable == null || onStartButtonClickListener == null) { return false; } iconRect = startButtonDrawable.copyBounds(); break; case DRAWABLE_POSITION_END: if (endButtonDrawable == null || onEndButtonClickListener == null) { return false; } iconRect = endButtonDrawable.copyBounds(); break; default: return false; } int viewCenterVertical = v.getPaddingTop() + ((v.getHeight() - v.getPaddingBottom()) - v.getPaddingTop()) / 2; if ((drawablePosition == DRAWABLE_POSITION_START && ltDirection == ViewCompat.LAYOUT_DIRECTION_LTR) || (drawablePosition == DRAWABLE_POSITION_END && ltDirection == ViewCompat.LAYOUT_DIRECTION_RTL)) { iconRect.offsetTo(viewPaddingStart, viewCenterVertical - iconRect.centerY()); } else if ((drawablePosition == DRAWABLE_POSITION_START && ltDirection == ViewCompat.LAYOUT_DIRECTION_RTL) || (drawablePosition == DRAWABLE_POSITION_END && ltDirection == ViewCompat.LAYOUT_DIRECTION_LTR)) { iconRect.offsetTo(v.getWidth() - viewPaddingEnd - iconRect.width(), viewCenterVertical - iconRect.centerY()); } else { return false; } iconRect.left = iconRect.left - extraTouchableAreaPx; iconRect.right = iconRect.right + extraTouchableAreaPx; iconRect.top = iconRect.top - extraTouchableAreaPx; iconRect.bottom = iconRect.bottom + extraTouchableAreaPx; return iconRect.contains(xTouch, yTouch); }
From source file:com.roselism.bottomsheet.BottomSheet.java
private void setListLayout() { // without divider, the height of gridview is correct if (!hasDivider()) { return;// w w w .j av a 2s . c om } list.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT < 16) { //noinspection deprecation list.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { list.getViewTreeObserver().removeOnGlobalLayoutListener(this); } View lastChild = list.getChildAt(list.getChildCount() - 1); if (lastChild != null) { list.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, lastChild.getBottom() + lastChild.getPaddingBottom() + list.getPaddingBottom())); } } }); }
From source file:com.xabber.android.ui.adapter.ChatMessageAdapter.java
private void setUpMessageBalloonBackground(View messageBalloon, ColorStateList darkColorStateList, int lightBackgroundId) { if (SettingsManager.interfaceTheme() == SettingsManager.InterfaceTheme.dark) { final Drawable originalBackgroundDrawable = messageBalloon.getBackground(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { originalBackgroundDrawable.setTintList(darkColorStateList); } else {/*from w w w.ja v a 2 s.co m*/ Drawable wrapDrawable = DrawableCompat.wrap(originalBackgroundDrawable); DrawableCompat.setTintList(wrapDrawable, darkColorStateList); int pL = messageBalloon.getPaddingLeft(); int pT = messageBalloon.getPaddingTop(); int pR = messageBalloon.getPaddingRight(); int pB = messageBalloon.getPaddingBottom(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { messageBalloon.setBackground(wrapDrawable); } else { messageBalloon.setBackgroundDrawable(wrapDrawable); } messageBalloon.setPadding(pL, pT, pR, pB); } } else { int pL = messageBalloon.getPaddingLeft(); int pT = messageBalloon.getPaddingTop(); int pR = messageBalloon.getPaddingRight(); int pB = messageBalloon.getPaddingBottom(); messageBalloon.setBackgroundResource(lightBackgroundId); messageBalloon.getBackground().setLevel(AccountManager.getInstance().getColorLevel(account)); messageBalloon.setPadding(pL, pT, pR, pB); } }
From source file:io.jari.geenstijl.Blog.java
public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.blog);//from w w w . j a v a 2s . co m super.onCreate(savedInstanceState); actionBar = getSupportActionBar(); final PullToRefreshLayout mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout); View drawer = findViewById(R.id.left_drawer); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerStateChanged(int newState) { super.onDrawerStateChanged(newState); enableImmersive(false, drawerLayout); } }; drawerLayout.setDrawerListener(drawerToggle); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); if (Build.VERSION.SDK_INT >= 19) { SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); drawer.setPadding(drawer.getPaddingLeft(), drawer.getPaddingTop() + config.getPixelInsetTop(true), drawer.getPaddingRight(), drawer.getPaddingBottom()); } ListView siteSwitch = (ListView) drawer.findViewById(R.id.site_switcher); ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.drawer_list_item, R.id.wrap_text, new String[] { "GeenStijl.nl", "GeenStijl.tv" }); siteSwitch.setAdapter(arrayAdapter); siteSwitch.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: API.setDomain("www.geenstijl.nl", Blog.this); break; case 1: API.setDomain("www.geenstijl.tv", Blog.this); break; } forceNoImmersive = true; enableImmersive(false, drawerLayout); drawerLayout.closeDrawers(); mPullToRefreshLayout.setRefreshing(true); new Thread(new Runnable() { public void run() { forceNoImmersive = true; try { final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext()); initUI(artikelen, false); runOnUiThread(new Runnable() { public void run() { mPullToRefreshLayout.setRefreshComplete(); forceNoImmersive = false; } }); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { forceNoImmersive = false; mPullToRefreshLayout.setRefreshComplete(); Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout" : e.getLocalizedMessage(), Style.ALERT).show(); } }); } } }).start(); } }); ListView applist = (ListView) findViewById(R.id.applist); applist.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, R.id.wrap_text, new String[] { getResources().getString(R.string.options), getResources().getString(R.string.about) })); applist.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: startActivity(new Intent(Intent.ACTION_VIEW, null, Blog.this, Settings.class)); break; case 1: new AboutDialog(Blog.this).show(getSupportFragmentManager(), "AbtDlg"); break; } drawerLayout.closeDrawers(); } }); reloadDrawer(); // Now setup the PullToRefreshLayout ActionBarPullToRefresh.from(this).allChildrenArePullable().listener(new OnRefreshListener() { public void onRefreshStarted(View view) { new Thread(new Runnable() { public void run() { forceNoImmersive = true; try { final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext()); initUI(artikelen, false); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { forceNoImmersive = false; mPullToRefreshLayout.setRefreshComplete(); Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout" : e.getLocalizedMessage(), Style.ALERT).show(); } }); } } }).start(); } }).setup(mPullToRefreshLayout); new Thread(new Runnable() { public void run() { try { final Artikel[] artikelen = API.getArticles(false, false, getApplicationContext()); initUI(artikelen, true); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { errorMessage = e.getMessage(); switchState(STATE_ERROR); } }); } } }).start(); //do changelog stuff SharedPreferences sPref = this.getSharedPreferences("geenstijl", 0); int version = 0; try { version = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException ignored) { } //is changelog already read if (!sPref.getBoolean("changelog-" + version, false)) { //set changelog to read sPref.edit().putBoolean("changelog-" + version, true).commit(); //show dialog LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.changelog, null); new AlertDialog.Builder(this).setTitle(R.string.changelog_title).setView(chgList) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create().show(); } }
From source file:com.kyo.fitssystemwindows.FitsSystemWindowsFrameLayout.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final boolean applyInsets = lastInsets != null && ViewCompat.getFitsSystemWindows(this); final int layoutDirection = ViewCompat.getLayoutDirection(this); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; }/*ww w . ja v a 2 s . co m*/ final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp.gravity == -1) { lp.gravity = DEFAULT_CHILD_GRAVITY; } if (applyInsets) { int cgrav = GravityCompat.getAbsoluteGravity(lp.gravity, layoutDirection); if (cgrav == -1) { cgrav = DEFAULT_CHILD_GRAVITY; } else { if ((cgrav & Gravity.VERTICAL_GRAVITY_MASK) == 0) { cgrav = cgrav | Gravity.TOP; } if ((cgrav & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) { cgrav = cgrav | (layoutDirection == LAYOUT_DIRECTION_LTR ? Gravity.LEFT : Gravity.RIGHT); } } if (ViewCompat.getFitsSystemWindows(child)) { final int l = child.getPaddingLeft(); final int t = child.getPaddingTop(); final int r = child.getPaddingRight(); final int b = child.getPaddingBottom(); IMPL.dispatchChildInsets(child, lp, cgrav, lastInsets); child.setPadding(l, t, r, b); } else { IMPL.applyMarginInsets(lp, cgrav, lastInsets); lp.leftMargin += lp.leftMargin2; lp.topMargin += lp.topMargin2; lp.rightMargin += lp.rightMargin2; lp.bottomMargin += lp.bottomMargin2; } } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE || ViewCompat.getFitsSystemWindows(child)) { continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); lp.leftMargin -= lp.leftMargin2; lp.topMargin -= lp.topMargin2; lp.rightMargin -= lp.rightMargin2; lp.bottomMargin -= lp.bottomMargin2; } }
From source file:com.umeng.comm.ui.fragments.BaseFeedsFragment.java
private void calculateLikePadding(View likeView) { if (mLikeItemPadding == 0) { mLikeItemPadding = likeView.getPaddingBottom() + likeView.getPaddingTop(); }//from w w w . j ava 2s . com }
From source file:com.andrada.sitracker.ui.fragment.PublicationInfoFragment.java
private void showCustomPositionedCrouton(String message, boolean success) { if (getActivity() == null) { return;//from w w w . ja v a 2 s. c o m } View view = getLayoutInflater(null).inflate(R.layout.crouton_custom_pos_textview, null); if (success) { view.findViewById(android.R.id.background).setBackgroundColor(Style.holoGreenLight); } else { view.findViewById(android.R.id.background).setBackgroundColor(Style.holoRedLight); } int topPadding = UIUtils.calculateActionBarSize(getActivity()); if (!mHasPhoto) { topPadding = (int) (newTop + mHeaderHeightPixels); } view.setPadding(view.getPaddingLeft(), topPadding, view.getPaddingRight(), view.getPaddingBottom()); TextView tv = (TextView) view.findViewById(android.R.id.text1); tv.setText(message); Crouton cr = Crouton.make(getActivity(), view); cr.setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_LONG).build()); cr.show(); }
From source file:base.PagerSlidingTabStrip.java
private void addTab(final int position, CharSequence title, View tabView) { TextView textView = (TextView) tabView.findViewById(R.id.tab_title); if (textView != null) { if (title != null) textView.setText(title);/*from w w w . j a v a2 s.com*/ float alpha = pager.getCurrentItem() == position ? tabTextSelectedAlpha : tabTextAlpha; ViewCompat.setAlpha(textView, alpha); } tabView.setFocusable(true); tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (pager.getCurrentItem() != position) { View tab = tabsContainer.getChildAt(pager.getCurrentItem()); notSelected(tab); pager.setCurrentItem(position); } } }); tabView.setPadding(tabPadding, tabView.getPaddingTop(), tabPadding, tabView.getPaddingBottom()); tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }