List of usage examples for android.widget RelativeLayout ALIGN_PARENT_BOTTOM
int ALIGN_PARENT_BOTTOM
To view the source code for android.widget RelativeLayout ALIGN_PARENT_BOTTOM.
Click Source Link
From source file:com.cranberrygame.phonegap.plugin.ad.Util.java
private void _showBannerAd(String position, String size) { this.position = position; this.size = size; if (bannerAdPreloaded) { bannerAdPreloaded = false;/*www . j a va 2 s . c o m*/ } else { _preloadBannerAd(); } //http://tigerwoods.tistory.com/11 //http://developer.android.com/reference/android/widget/RelativeLayout.html //http://stackoverflow.com/questions/24900725/admob-banner-poitioning-in-android-on-bottom-of-the-screen-using-no-xml-relative RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(AdView.LayoutParams.WRAP_CONTENT, AdView.LayoutParams.WRAP_CONTENT); if (position.equals("top-left")) { Log.d("Admob", "top-left"); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else if (position.equals("top-center")) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } else if (position.equals("top-right")) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else if (position.equals("left")) { params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("center")) { params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("right")) { params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("bottom-left")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else if (position.equals("bottom-center")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } else if (position.equals("bottom-right")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } //bannerViewLayout.addView(bannerView, params); bannerView.setLayoutParams(params); bannerViewLayout.addView(bannerView); }
From source file:com.spoiledmilk.ibikecph.LeftMenu.java
@SuppressWarnings("deprecation") public void updateControls() { LOG.d("LeftMenu updateControls"); if (!IbikeApplication.isUserLogedIn()) { favoritesContainer.setBackgroundDrawable(null); textFavoriteHint.setTextColor(getHintDisabledTextColor()); textNewFavorite.setTextColor(Color.rgb(60, 60, 60)); imgAdd.setImageResource(R.drawable.fav_plus_none); favoritesList.setAdapter(null);// w w w . j av a2 s . c o m RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, Util.dp2px(150)); favoritesContainerHeight = Util.dp2px(150); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.BELOW, favoritesHeaderContainer.getId()); favoritesContainer.setLayoutParams(params); addContainer.setPadding((int) (Util.getScreenWidth() / 7 + Util.dp2px(7)), (int) Util.dp2px(5), 0, (int) Util.dp2px(34)); // getView().findViewById(R.id.imgRightArrow).setVisibility(View.INVISIBLE); textFavoriteHint.setVisibility(View.VISIBLE); btnEditFavorites.setVisibility(View.INVISIBLE); btnEditFavorites.setEnabled(false); lastListDivider.setVisibility(View.GONE); params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.topMargin = Util.dp2px(3); // imgAdd.setLayoutParams(params); textNewFavorite.setPadding(Util.dp2px(0), 0, 0, Util.dp2px(0)); params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.bottomMargin = Util.getDensity() >= 2 ? Util.dp2px(40) : Util.dp2px(20); addContainer.setLayoutParams(params); addContainer.setPadding(Util.getDensity() >= 2 ? Util.dp2px(60) : Util.dp2px(40), Util.dp2px(7), 0, Util.dp2px(7)); addContainer.setBackgroundColor(Color.TRANSPARENT); addContainer.setClickable(false); } else if (favorites == null || favorites.size() == 0) { favoritesContainer.setBackgroundResource(R.drawable.add_fav_background_selector); addContainer.setBackgroundColor(Color.TRANSPARENT);// addContainer.setBackgroundResource(R.drawable.add_fav_background_selector); lastListDivider.setVisibility(View.GONE); favoritesList.setVisibility(View.GONE); textFavoriteHint.setVisibility(View.VISIBLE); // getView().findViewById(R.id.imgRightArrow).setVisibility(View.VISIBLE); favoritesContainer.setClickable(true); imgAdd.setImageResource(R.drawable.fav_add); textFavoriteHint.setTextColor(getHintEnabledTextColor()); textNewFavorite.setTextColor(getAddFavoriteTextColor()); btnEditFavorites.setVisibility(View.INVISIBLE); btnEditFavorites.setEnabled(false); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, Util.dp2px(150)); favoritesContainerHeight = Util.dp2px(150); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.BELOW, getView().findViewById(R.id.favoritesHeaderContainer).getId()); favoritesContainer.setLayoutParams(params); addContainer.setPadding((int) (Util.getScreenWidth() / 7 + Util.dp2px(7)), (int) Util.dp2px(5), 0, (int) Util.dp2px(34)); params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.topMargin = Util.dp2px(3); // imgAdd.setLayoutParams(params); textNewFavorite.setPadding(0, 0, 0, 0); params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.bottomMargin = Util.getDensity() >= 2 ? Util.dp2px(40) : Util.dp2px(20); addContainer.setLayoutParams(params); addContainer.setPadding(Util.getDensity() >= 2 ? Util.dp2px(0) : Util.dp2px(10), Util.dp2px(7), 0, Util.dp2px(7)); addContainer.setClickable(false); } else { // Loged in, and there is a list of favorites favoritesList.clearAnimations(); favoritesList.setVisibility(View.VISIBLE); if (listAdapter != null) { ((FavoritesAdapter) listAdapter).setIsEditMode(isEditMode); btnEditFavorites.setVisibility(isEditMode ? View.INVISIBLE : View.VISIBLE); btnEditFavorites.setEnabled(!isEditMode); btnDone.setVisibility(isEditMode ? View.VISIBLE : View.INVISIBLE); btnDone.setEnabled(isEditMode); } textFavoriteHint.setVisibility(View.GONE); if (getView() != null) { addContainer.setVisibility(isEditMode ? View.GONE : View.VISIBLE); // getView().findViewById(R.id.imgRightArrow).setVisibility(View.GONE); getView().findViewById(R.id.favoritesContainer).setClickable(false); int count = favorites.size(); int listHeight = count * (menuItemHeight) + Util.dp2px(1) * count; int viewHeight = (int) (Util.getScreenHeight() - Util.dp2px(26)); // // screen height without the // notifications bar int avaliableHeight = viewHeight - (menuItemHeight * (getMenuItemsCount() + (isEditMode ? 0 : 1))) - (getMenuItemsCount() * dividerHeight); LOG.d("available height = " + avaliableHeight); LOG.d("list height = " + listHeight); if (listHeight > avaliableHeight) { listHeight = avaliableHeight; } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, (isEditMode ? listHeight : (listHeight + menuItemHeight))); favoritesContainerHeight = (isEditMode ? listHeight : (listHeight + menuItemHeight)); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.BELOW, getView().findViewById(R.id.horizontalDivider1).getId()); favoritesContainer.setLayoutParams(params); params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, listHeight); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); getView().findViewById(R.id.favoritesListContainer).setLayoutParams(params); imgAdd.setImageResource(R.drawable.fav_add); textFavoriteHint.setTextColor(Color.WHITE); textNewFavorite.setTextColor(getAddFavoriteTextColor()); lastListDivider.setVisibility( (isEditMode || favorites.size() <= getFavoritesVisibleItemCount()) ? View.GONE : View.VISIBLE); updateFavoritesContainer(); addContainer.setPadding((int) Util.dp2px(30), (int) Util.dp2px(0), 0, (int) Util.dp2px(0)); params = new RelativeLayout.LayoutParams(Util.dp2px(14), Util.dp2px(14)); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.CENTER_VERTICAL); params.bottomMargin = Util.dp2px(0); // imgAdd.setLayoutParams(params); params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, menuItemHeight); params.addRule(RelativeLayout.BELOW, getView().findViewById(R.id.favoritesListContainer).getId()); if (!isEditMode) { addContainer.setLayoutParams(params); } addContainer.setBackgroundResource(R.drawable.add_fav_background_selector); addContainer.setClickable(true); textNewFavorite.setPadding(Util.dp2px(4), 0, 0, 0); ((FavoritesAdapter) listAdapter).notifyDataSetChanged(); } } }
From source file:lemonlabs.android.expandablebuttonmenu.ExpandableButtonMenu.java
/** * Manually invalidate views for pre-Honeycomb devices *//*from w w w . ja va 2 s.c o m*/ private void invalidateViewsForPreHC() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { final int EXTRA_BOTTOM_MARGIN = (int) (sWidth * (mainButtonSize - otherButtonSize) / 2); if (mExpanded) { ViewHelper.setAlpha(mMidContainer, 0f); ViewHelper.setAlpha(mRightContainer, 0f); ViewHelper.setAlpha(mLeftContainer, 0f); ViewPropertyAnimator.animate(mMidContainer).setDuration(0).translationYBy(-TRANSLATION_Y); ViewPropertyAnimator.animate(mRightContainer).setDuration(0).translationYBy(-TRANSLATION_Y) .translationXBy(TRANSLATION_X); ViewPropertyAnimator.animate(mLeftContainer).setDuration(0).translationYBy(-TRANSLATION_Y) .translationXBy(-TRANSLATION_X); RelativeLayout.LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(0, 0, 0, (int) (sHeight * bottomPadding + EXTRA_BOTTOM_MARGIN)); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); mMidContainer.setLayoutParams(params); mRightContainer.setLayoutParams(params); mLeftContainer.setLayoutParams(params); } else { final int CENTER_RIGHT_POSITION = mMidContainer.getRight(); final int EXTRA_MARGIN = mLeftContainer.getLeft() - (int) (CENTER_RIGHT_POSITION - TRANSLATION_X); ViewPropertyAnimator.animate(mMidContainer).setDuration(0).translationYBy(TRANSLATION_Y); ViewPropertyAnimator.animate(mRightContainer).setDuration(0).translationYBy(TRANSLATION_Y) .translationXBy(-TRANSLATION_X); ViewPropertyAnimator.animate(mLeftContainer).setDuration(0).translationYBy(TRANSLATION_Y) .translationXBy(TRANSLATION_X); RelativeLayout.LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.setMargins(0, 0, 0, (int) (sHeight * bottomPadding + TRANSLATION_Y + EXTRA_BOTTOM_MARGIN)); mMidContainer.setLayoutParams(params); params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.RIGHT_OF, mMidContainer.getId()); params.setMargins(EXTRA_MARGIN, 0, 0, (int) (sHeight * bottomPadding + TRANSLATION_Y + EXTRA_BOTTOM_MARGIN)); mRightContainer.setLayoutParams(params); params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.LEFT_OF, mMidContainer.getId()); params.setMargins(0, 0, EXTRA_MARGIN, (int) (sHeight * bottomPadding + TRANSLATION_Y + EXTRA_BOTTOM_MARGIN)); mLeftContainer.setLayoutParams(params); } } }
From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java
private void keyboardClosed() { if (keyboardShown) { try {//from w w w .java 2s .c o m showSystemUI(); View buttons = getActivity().findViewById(R.id.send_image_buttons); View viewPager = getActivity().findViewById(R.id.send_image_view_pager); RelativeLayout.LayoutParams viewPagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); viewPagerParams.addRule(RelativeLayout.ABOVE, R.id.send_image_overview); viewPagerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); viewPagerParams.addRule(RelativeLayout.ALIGN_PARENT_START); viewPager.setLayoutParams(viewPagerParams); RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imageParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); images.get(current).getImageLayout().setLayoutParams(imageParams); if (images.size() > 1) getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE); buttons.setVisibility(View.VISIBLE); } catch (Exception e) { e.printStackTrace(); } keyboardShown = false; } }
From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java
/** * Lays out the body using the front images. *//*from w w w. j a va2 s . c o m*/ private void setMaleFront() { front = true; RelativeLayout.LayoutParams lp; lp = new RelativeLayout.LayoutParams(dipToPixels(42), dipToPixels(65)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(304); head.setLayoutParams(lp); head.setBackground(getResources().getDrawable(R.drawable.male_head_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(58), dipToPixels(101)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(206); torso.setLayoutParams(lp); torso.setBackground(getResources().getDrawable(R.drawable.male_torso_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(67), dipToPixels(41)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(168); shorts.setLayoutParams(lp); shorts.setBackground(getResources().getDrawable(R.drawable.male_groin_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(37), dipToPixels(67)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(108); lp.leftMargin = dipToPixels(141); r_top.setLayoutParams(lp); r_top.setBackground(getResources().getDrawable(R.drawable.male_leftthigh_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(24), dipToPixels(76)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(40); lp.leftMargin = dipToPixels(137); r_bot.setLayoutParams(lp); r_bot.setBackground(getResources().getDrawable(R.drawable.male_leftcalf_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(24), dipToPixels(42)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(0); lp.leftMargin = dipToPixels(129); r_foot.setLayoutParams(lp); r_foot.setBackground(getResources().getDrawable(R.drawable.male_leftfoot_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(37), dipToPixels(67)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(109); lp.leftMargin = dipToPixels(182); l_top.setLayoutParams(lp); l_top.setBackground(getResources().getDrawable(R.drawable.male_rightthigh_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(24), dipToPixels(76)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(41); lp.leftMargin = dipToPixels(199); l_bot.setLayoutParams(lp); l_bot.setBackground(getResources().getDrawable(R.drawable.male_rightcalf_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(24), dipToPixels(42)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(1); lp.leftMargin = dipToPixels(207); l_foot.setLayoutParams(lp); l_foot.setBackground(getResources().getDrawable(R.drawable.male_rightfoot_foot_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(73), dipToPixels(92)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(215); lp.leftMargin = dipToPixels(87); r_arm.setLayoutParams(lp); r_arm.setBackground(getResources().getDrawable(R.drawable.male_leftarm_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(35), dipToPixels(35)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(186); lp.leftMargin = dipToPixels(61); r_hand.setLayoutParams(lp); r_hand.setBackground(getResources().getDrawable(R.drawable.male_lefthand_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(73), dipToPixels(92)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(215); lp.leftMargin = dipToPixels(200); l_arm.setLayoutParams(lp); l_arm.setBackground(getResources().getDrawable(R.drawable.male_rightarm_front_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(35), dipToPixels(35)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(186); lp.leftMargin = dipToPixels(265); l_hand.setLayoutParams(lp); l_hand.setBackground(getResources().getDrawable(R.drawable.male_righthand_front_3x)); bodyLayout.invalidate(); }
From source file:com.appfeel.cordova.admob.AdMobAds.java
/** * Parses the show ad input parameters and runs the show ad action on the UI thread. * /*from w w w.j a va2 s . com*/ * @param inputs The JSONArray representing input parameters. This function expects the first object in the array to be a JSONObject with the input * parameters. * @return A PluginResult representing whether or not an ad was requested succcessfully. Listen for onReceiveAd() and onFailedToReceiveAd() callbacks to see * if an ad was successfully retrieved. */ private PluginResult executeShowBannerAd(final boolean show, final CallbackContext callbackContext) { if (adView == null) { return new PluginResult(Status.ERROR, "adView is null, call createBannerView first."); } cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (show == isBannerVisible) { // no change } else if (show) { if (adView.getParent() != null) { ((ViewGroup) adView.getParent()).removeView(adView); } if (isBannerOverlap) { RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); if (isOffsetStatusBar) { int titleBarHeight = 0; Rect rectangle = new Rect(); Window window = AdMobAds.this.cordova.getActivity().getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectangle); if (isBannerAtTop) { if (rectangle.top == 0) { int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); titleBarHeight = contentViewTop - rectangle.top; } params2.topMargin = titleBarHeight; } else { if (rectangle.top > 0) { int contentViewBottom = window.findViewById(Window.ID_ANDROID_CONTENT) .getBottom(); titleBarHeight = contentViewBottom - rectangle.bottom; } params2.bottomMargin = titleBarHeight; } } else if (isBannerAtTop) { params2.addRule(RelativeLayout.ALIGN_PARENT_TOP); } else { params2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } if (adViewLayout == null) { adViewLayout = new RelativeLayout(cordova.getActivity()); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); if (CORDOVA_4) { ((ViewGroup) webView.getView().getParent()).addView(adViewLayout, params); } else { ((ViewGroup) webView).addView(adViewLayout, params); } } adViewLayout.addView(adView, params2); adViewLayout.bringToFront(); } else { if (CORDOVA_4) { ViewGroup wvParentView = (ViewGroup) webView.getView().getParent(); if (parentView == null) { parentView = new LinearLayout(webView.getContext()); } if (wvParentView != null && wvParentView != parentView) { wvParentView.removeView(webView.getView()); ((LinearLayout) parentView).setOrientation(LinearLayout.VERTICAL); parentView.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); webView.getView().setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0F)); parentView.addView(webView.getView()); cordova.getActivity().setContentView(parentView); } } else { parentView = (ViewGroup) ((ViewGroup) webView).getParent(); } if (isBannerAtTop) { parentView.addView(adView, 0); } else { parentView.addView(adView); } parentView.bringToFront(); parentView.requestLayout(); } adView.setVisibility(View.VISIBLE); isBannerVisible = true; } else { adView.setVisibility(View.GONE); isBannerVisible = false; } if (callbackContext != null) { callbackContext.success(); } } }); return null; }
From source file:com.jomendezdev.cordova.admob.AdMobAds.java
/** * Parses the show ad input parameters and runs the show ad action on the UI thread. * //from w ww. j a va 2s. co m * @param inputs The JSONArray representing input parameters. This function expects the first object in the array to be a JSONObject with the input * parameters. * @return A PluginResult representing whether or not an ad was requested succcessfully. Listen for onReceiveAd() and onFailedToReceiveAd() callbacks to see * if an ad was successfully retrieved. */ private PluginResult executeShowBannerAd(final boolean show, final CallbackContext callbackContext) { if (adView == null) { return new PluginResult(Status.ERROR, "adView is null, call createBannerView first."); } cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (show == isBannerVisible) { // no change } else if (show) { if (adView.getParent() != null) { ((ViewGroup) adView.getParent()).removeView(adView); } if (isBannerOverlap) { RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); if (isOffsetStatusBar) { int titleBarHeight = 0; Rect rectangle = new Rect(); Window window = AdMobAds.this.cordova.getActivity().getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectangle); if (isBannerAtTop) { if (rectangle.top == 0) { int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); titleBarHeight = contentViewTop - rectangle.top; } params2.topMargin = titleBarHeight; } else { if (rectangle.top > 0) { int contentViewBottom = window.findViewById(Window.ID_ANDROID_CONTENT) .getBottom(); titleBarHeight = contentViewBottom - rectangle.bottom; } params2.bottomMargin = titleBarHeight; } } else if (isBannerAtTop) { params2.addRule(RelativeLayout.ALIGN_PARENT_TOP); } else { params2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } adViewLayout.addView(adView, params2); adViewLayout.bringToFront(); } else { ViewGroup parentView = (ViewGroup) webView.getParent(); if (isBannerAtTop) { parentView.addView(adView, 0); } else { parentView.addView(adView); } parentView.bringToFront(); } adView.setVisibility(View.VISIBLE); isBannerVisible = true; } else { adView.setVisibility(View.GONE); isBannerVisible = false; } if (callbackContext != null) { callbackContext.success(); } } }); return null; }
From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java
private void keyboardOpened() { if (!keyboardShown) { try {/*from w w w. j a va 2 s . co m*/ View buttons = getActivity().findViewById(R.id.send_image_buttons); View viewPager = getActivity().findViewById(R.id.send_image_view_pager); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_START); viewPager.setLayoutParams(params); RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imageParams.addRule(RelativeLayout.ABOVE, R.id.send_image_description_layout); images.get(current).getImageLayout().setLayoutParams(imageParams); if (images.size() > 1) getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE); buttons.setVisibility(View.GONE); hideSystemUI(); } catch (Exception e) { e.printStackTrace(); } keyboardShown = true; } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the auto layout./*from w w w.java 2 s . c om*/ * It contains toggle button to switch auto state, two text view to indicate auto messages. * * @return the relative layout */ private RelativeLayout createAutoLayout() { RelativeLayout autoLayout = new RelativeLayout(this); autoLayout.setPadding(10, 5, 10, 10); autoLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 80)); TextView autoText = new TextView(this); RelativeLayout.LayoutParams autoTextLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); autoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); autoTextLayout.addRule(RelativeLayout.CENTER_VERTICAL); autoText.setLayoutParams(autoTextLayout); autoText.setText("Auto Discovery"); ToggleButton autoButton = new ToggleButton(this); autoButton.setWidth(150); RelativeLayout.LayoutParams autoButtonLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); autoButtonLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); autoButtonLayout.addRule(RelativeLayout.CENTER_VERTICAL); autoButton.setLayoutParams(autoButtonLayout); autoButton.setChecked(autoMode); autoButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { appSettingsView.removeViewAt(2); currentServer = ""; if (isChecked) { IPAutoDiscoveryServer.isInterrupted = false; appSettingsView.addView(constructAutoServersView(), 2); } else { IPAutoDiscoveryServer.isInterrupted = true; appSettingsView.addView(constructCustomServersView(), 2); } AppSettingsModel.setAutoMode(AppSettingsActivity.this, isChecked); } }); TextView infoText = new TextView(this); RelativeLayout.LayoutParams infoTextLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); infoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); infoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); infoText.setLayoutParams(infoTextLayout); infoText.setTextSize(10); infoText.setText("Turn off auto-discovery to input controller url manually."); autoLayout.addView(autoText); autoLayout.addView(autoButton); autoLayout.addView(infoText); return autoLayout; }
From source file:net.e_fas.oss.tabijiman.MapsActivity.java
@Override public void onMapReady(GoogleMap googleMap) { e_print("onMapReady"); mMap = googleMap;/* w w w. j a va 2 s . c om*/ GoFukuiButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CameraPosition cameraPos = new CameraPosition.Builder().target(new LatLng(36.0642988, 136.220012)) .zoom(10.0f).bearing(0).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); GoFukuiButton.setVisibility(View.GONE); } }); CameraPosition cameraPos = new CameraPosition.Builder().target(new LatLng(36.0614444, 136.2229937)) .zoom(zoomLevel).bearing(0).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); // ?? mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { Toast.makeText(getApplicationContext(), marker.getTitle(), Toast.LENGTH_LONG).show(); return false; } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { View view = getLayoutInflater().inflate(R.layout.info_window, null); // TextView title = (TextView) view.findViewById(R.id.info_title); title.setText(marker.getTitle()); e_print("marker_Snippet >> " + marker.getSnippet()); if (marker.getSnippet() == null) { view.findViewById(R.id.info_address).setVisibility(View.GONE); } else { TextView address = (TextView) view.findViewById(R.id.info_address); address.setText(marker.getSnippet()); } return view; } }); mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { e_print("title_name >> " + marker.getTitle()); //DB()?? SQLiteDatabase dbRead = helper.getReadableDatabase(); //SQL String select_frame_sql = "SELECT * FROM frame WHERE `name` = ? AND `lat` = ? AND `lng` = ?"; String select_place_sql = "SELECT * FROM place WHERE `name` = ? AND `lat` = ? AND `lng` = ?"; //SQL? Cursor cursor = dbRead.rawQuery(select_place_sql, new String[] { marker.getTitle(), String.valueOf(marker.getPosition().latitude), String.valueOf(marker.getPosition().longitude) }); e_print("cursor_count >> " + cursor.getCount()); if (cursor.getCount() != 0) { cursor.moveToFirst(); e_print("lat >> " + marker.getPosition().latitude + " lng >> " + marker.getPosition().longitude); Intent MoreInfo = new Intent(getApplicationContext(), MoreInfo.class); MoreInfo.putExtra("id", cursor.getInt(cursor.getColumnIndex("_id"))); MoreInfo.putExtra("cat", "place"); cursor.close(); startActivity(MoreInfo); } else { cursor.close(); //SQL? Cursor cursor2 = dbRead.rawQuery(select_frame_sql, new String[] { marker.getTitle(), String.valueOf(marker.getPosition().latitude), String.valueOf(marker.getPosition().longitude) }); cursor2.moveToFirst(); /* * distance[0] = [??] * distance[1] = [???] * distance[2] = [???] */ float[] distance = getDistance(nowLocation.latitude, nowLocation.longitude, marker.getPosition().latitude, marker.getPosition().longitude); Intent MoreInfo = new Intent(getApplicationContext(), MoreInfo.class); MoreInfo.putExtra("dist", distance[0]); MoreInfo.putExtra("id", cursor2.getInt(cursor2.getColumnIndex("_id"))); MoreInfo.putExtra("cat", "frame"); cursor2.close(); startActivity(MoreInfo); } } }); mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() { @Override public boolean onMyLocationButtonClick() { Location location = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); e_print("MyLocation >> " + location); Toast.makeText(getApplicationContext(), "location >> " + location, Toast.LENGTH_SHORT).show(); return false; } }); mMap.setMyLocationEnabled(true); // MyLocationButton? UiSettings settings = mMap.getUiSettings(); settings.setMyLocationButtonEnabled(true); //?? View locationButton = ((View) super.findViewById(Integer.parseInt("1")).getParent()) .findViewById(Integer.parseInt("2")); RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams(); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); rlp.setMargins(0, 0, 180, 180); print("mMap >> insert"); for (String provider : providers) { e_print("enable_providers >> " + provider); mLocationManager.requestLocationUpdates(provider, 3000, 0, this); } if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { e_print("Provider_enable >> NETWORK"); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this); } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { e_print("Providers_enable >> GPS"); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); } else { e_print("All_Providers_Disable"); } }