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.derrick.movies.MovieDetailsActivity.java
private void setTrailers(Videos videos) { videosList = videos.getResults();//from w w w . j a v a 2s.c o m int size = videosList.size(); if (size == 1) { txt_title_trailer.setText("Trailer"); } for (int i = 0; i < size; i++) { Result result = videosList.get(i); String url = IMAGE_YOUTUBE + result.getKey() + YOUTUBE_QUALITY; ImageView imageView; ImageView imageView_play; TextView txt_name; ViewGroup.LayoutParams lp = new RelativeLayout.LayoutParams(70, 70); ViewGroup.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); if (size == 1) { imageView = new ImageView(getApplicationContext()); imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } else { imageView = new ImageView(getApplicationContext()); imageView .setLayoutParams(new RelativeLayout.LayoutParams(500, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } imageView_play = new ImageView(getApplicationContext()); imageView_play.setLayoutParams(lp); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView_play .getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); imageView_play.setLayoutParams(layoutParams); imageView_play.setScaleType(ImageView.ScaleType.CENTER_CROP); Drawable drawable = getResources() .getDrawable(getResources().getIdentifier("play", "drawable", getPackageName())); imageView_play.setImageDrawable(drawable); txt_name = new TextView(getApplicationContext()); txt_name.setLayoutParams(lp2); RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) txt_name.getLayoutParams(); layoutParams2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutParams2.setMargins(8, 8, 8, 16); txt_name.setLayoutParams(layoutParams2); txt_name.setTypeface(robotoCondensed); txt_name.setText(result.getName()); txt_name.setTextColor(getResources().getColor(R.color.colorWhite)); Glide.with(getBaseContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { return false; } }).into(imageView); // trailerSlider.addView(imageView_play); relativeLayout.addView(imageView); relativeLayout.addView(imageView_play); relativeLayout.addView(txt_name); trailerSlider.addView(relativeLayout); } }
From source file:com.pemikir.youtubeplus.VideoItemDetailFragment.java
@Override public void onActivityCreated(Bundle savedInstanceBundle) { super.onActivityCreated(savedInstanceBundle); FloatingActionButton playVideoButton = (FloatingActionButton) getActivity() .findViewById(R.id.playVideoButton); if (PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean(getString(R.string.leftHandLayout), false) && checkIfLandscape()) { RelativeLayout.LayoutParams oldLayout = (RelativeLayout.LayoutParams) playVideoButton.getLayoutParams(); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layoutParams.setMargins(oldLayout.leftMargin, oldLayout.topMargin, oldLayout.rightMargin, oldLayout.rightMargin);//from w w w.j a v a 2 s. co m playVideoButton.setLayoutParams(layoutParams); } playVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActionBarHandler.getHandler().playVideo(); } }); }
From source file:com.spoiledmilk.ibikecph.map.MapActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); Util.init(getWindowManager()); LOG.d("Map activity onCreate"); this.maxSlide = (int) (4 * Util.getScreenWidth() / 5); this.setContentView(R.layout.main_map_activity); mapFragment = new SMMapFragment(); FragmentManager fm = this.getSupportFragmentManager(); fm.beginTransaction().add(R.id.map_container, mapFragment).commit(); mapContainer = (FrameLayout) findViewById(R.id.map_container); progressBar = (ProgressBar) findViewById(R.id.progressBar); leftContainer = (RelativeLayout) findViewById(R.id.leftContainer); pinInfoLayout = (RelativeLayout) findViewById(R.id.pinInfoLayout); pinInfoLine1 = (TextView) pinInfoLayout.findViewById(R.id.pinAddressLine1); pinInfoLine1.setTypeface(IbikeApplication.getBoldFont()); btnStart = (Button) findViewById(R.id.btnStart); btnStart.setOnClickListener(new OnClickListener() { @Override// w ww .j ava 2 s. c om public void onClick(View v) { pinInfoLayout.setClickable(false); LOG.d("find route"); Location start = SMLocationManager.getInstance().getLastValidLocation(); if (start == null) { showRouteNotFoundDlg(); } else { progressBar.setVisibility(View.VISIBLE); new SMHttpRequest().getRoute(start, mapFragment.getPinLocation(), null, MapActivity.this); } } }); btnSaveFavorite = (ImageButton) findViewById(R.id.btnSaveFavorite); btnSaveFavorite.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { DB db = new DB(MapActivity.this); try { if (IbikeApplication.isUserLogedIn()) { if (isSaveFaveoriteEnabled) { favoritesData = new FavoritesData(address.street + " " + address.houseNumber, address.street + " " + address.houseNumber, "favorite", currentLocation.getLatitude(), currentLocation.getLongitude(), -1); db.saveFavorite(favoritesData, MapActivity.this, true); String st = favoritesData.getName() + " - (" + favoritesData.getLatitude() + "," + favoritesData.getLongitude() + ")"; IbikeApplication.getTracker().sendEvent("Favorites", "Save", st, (long) 0); leftMenu.reloadFavorites(); btnSaveFavorite.setImageResource(R.drawable.drop_pin_add_fav_btn_active); } else if (favoritesData != null) { db.deleteFavorite(favoritesData, MapActivity.this); leftMenu.reloadFavorites(); btnSaveFavorite.setImageResource(R.drawable.drop_pin_selector); } isSaveFaveoriteEnabled = !isSaveFaveoriteEnabled; } else { launchLoginDialog(); } } catch (Exception e) { } } }); btnTrack = (ImageButton) findViewById(R.id.btnTrack); btnTrack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mapFragment.getTrackingMode()) { startTrackingUser(); } } }); LOG.d("Map activity btnTrack = " + btnTrack); rootLayout = (RelativeLayout) findViewById(R.id.rootLayout); FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams((int) (9 * Util.getScreenWidth() / 5), FrameLayout.LayoutParams.MATCH_PARENT); rootLayout.setLayoutParams(rootParams); parentContainer = (RelativeLayout) findViewById(R.id.parent_container); imgSwiper = (ImageView) findViewById(R.id.imgSwiper); imgSwiper.setOnTouchListener(new OnTouchListener() { // Swipe the view horizontally @Override public boolean onTouch(View v, MotionEvent event) { return onImgSwiperTouch(v, event); } }); mapDisabledView = findViewById(R.id.mapDisabledView); mapDisabledView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // used to disable the map touching when sliden return onImgSwiperTouch(v, event); // true } }); btnSearch = (ImageButton) findViewById(R.id.btnSearch); btnSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent(MapActivity.this, getSearchActivity()); startActivityForResult(i, 2); overridePendingTransition(R.anim.slide_in_down, R.anim.fixed); } }); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth() * 4 / 5, RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); findViewById(R.id.leftContainer).setLayoutParams(params); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); findViewById(R.id.parent_container).setLayoutParams(params); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); findViewById(R.id.pinInfoLayout).setLayoutParams(params); leftMenu = getLeftMenu(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); if (savedInstanceState == null) { fragmentTransaction.add(R.id.leftContainer, leftMenu); } else { fragmentTransaction.replace(R.id.leftContainer, leftMenu); } fragmentTransaction.commit(); findViewById(R.id.rootLayout).invalidate(); if (Config.HOCKEY_UPDATES_ENABLED) { UpdateManager.register(this, Config.HOCKEY_APP_ID); } }
From source file:tv.acfun.a63.CommentsActivity.java
private void initCommentsBar() { mCommentBar = findViewById(R.id.comments_bar); if (ActionBarUtil.hasSB() && getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { RelativeLayout.LayoutParams params = (LayoutParams) mCommentBar.getLayoutParams(); params.bottomMargin = getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); mCommentBar.setLayoutParams(params); }/*from w w w . j av a2 s.c o m*/ mBtnSend = (ImageButton) findViewById(R.id.comments_send_btn); mCommentText = (EditText) findViewById(R.id.comments_edit); mBtnEmotion = findViewById(R.id.comments_emotion_btn); mEmotionGrid = (GridView) findViewById(R.id.emotions); mBtnSend.setOnClickListener(this); mBtnEmotion.setOnClickListener(this); mEmotionGrid.setAdapter(mEmotionAdapter); mEmotionGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int index = mCommentText.getSelectionEnd(); Editable text = mCommentText.getText(); String emotion = parent.getItemAtPosition(position).toString(); text.insert(index, emotion); EmotionView v = (EmotionView) parent.getAdapter().getView(position, null, null); Drawable drawable = TextViewUtils.convertViewToDrawable(v); drawable.setBounds(0, 0, drawable.getIntrinsicWidth() / 2, drawable.getIntrinsicHeight() / 2); text.setSpan(new ImageSpan(drawable), index, index + emotion.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }); }
From source file:com.cloud.widget.viewpager.PagerSlidingTabStrip.java
/** * Modify by Cloud on 15/12/1.//from w ww . ja va2 s. c om * TabViewViewGroup */ private void addTextTab(final int position, String title, float num, boolean hasIndicator, boolean hasNum, int tabNum) { relativeLayout = new RelativeLayout(getContext()); if (hasIndicator) { if (hasNum) { //title RelativeLayout.LayoutParams titleLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); titleText = new TextView(getContext()); titleText.setText(title); titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); titleText.setTypeface(tabTypeface, tabTypefaceStyle); titleText.setTextAppearance(getContext(), tabDefaultTextAppearance); titleLp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); titleText.setLayoutParams(titleLp); // RelativeLayout.LayoutParams indicatorLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); indicatorText = new TextView(getContext()); indicatorText.setHeight(px2dip(getContext(), 50)); indicatorText.setWidth(px2dip(getContext(), screenWidth)); indicatorText.setText("" + String.valueOf(num)); indicatorText.setGravity(Gravity.CENTER); indicatorText.setSingleLine(); indicatorLp.topMargin = 5; indicatorLp.bottomMargin = 5; indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorText.setLayoutParams(indicatorLp); relativeLayout.addView(indicatorText); relativeLayout.addView(titleText); } else { //title RelativeLayout.LayoutParams titleLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); titleText = new TextView(getContext()); titleText.setText(title); titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); titleText.setTypeface(tabTypeface, tabTypefaceStyle); titleText.setTextAppearance(getContext(), tabDefaultTextAppearance); titleText.setLayoutParams(titleLp); relativeLayout.addView(titleText); } } else { RelativeLayout.LayoutParams titleLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); titleText = new TextView(getContext()); titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); titleText.setTypeface(tabTypeface, tabTypefaceStyle); titleText.setTextAppearance(getContext(), tabDefaultTextAppearance); titleText.setLayoutParams(titleLp); relativeLayout.addView(titleText); if (num % 1 == 0) { titleText.setText(title + "(" + String.valueOf((int) num) + ")"); } else { titleText.setText(title + "(" + String.valueOf(num) + ")"); } } if (num != 0 && hasIndicator && !hasNum) { // RelativeLayout.LayoutParams indicatorLp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); indicatorText = new TextView(getContext()); indicatorText.setHeight(px2dip(getContext(), 50)); indicatorText.setWidth(px2dip(getContext(), 50)); if (num % 1 == 0) { indicatorText.setText(String.valueOf((int) num)); } else { indicatorText.setText(String.valueOf(num)); } indicatorText.setGravity(Gravity.CENTER); indicatorText.setSingleLine(); indicatorText .setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.indicator_red_shape)); indicatorText.setTextAppearance(getContext(), indicatorNum); indicatorLp.topMargin = 10; if (tabNum == 4) { indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); } else { indicatorLp.leftMargin = screenWidth / 4 + screenWidth / 16; } indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); indicatorText.setLayoutParams(indicatorLp); relativeLayout.addView(indicatorText); } addTab(position, relativeLayout); }
From source file:com.luseen.spacenavigation.SpaceNavigationView.java
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); /**/*from ww w . j av a 2 s . c o m*/ * Restore current item index from savedInstance */ restoreCurrentItem(); /** * Trow exceptions if items size is greater than 4 or lesser than 2 */ if (spaceItems.size() < 2) { throw new NullPointerException("Your space item count must be greater than 1 ," + " your current items count is : " + spaceItems.size()); } if (spaceItems.size() > 4) { throw new IndexOutOfBoundsException( "Your items count maximum can be 4," + " your current items count is : " + spaceItems.size()); } /** * Get left or right content width */ contentWidth = (w - spaceNavigationHeight) / 2; /** * Removing all view for not being duplicated */ removeAllViews(); /** * Views initializations and customizing */ RelativeLayout mainContent = new RelativeLayout(context); RelativeLayout centreBackgroundView = new RelativeLayout(context); LinearLayout leftContent = new LinearLayout(context); LinearLayout rightContent = new LinearLayout(context); BezierView centreContent = buildBezierView(); FloatingActionButton fab = new FloatingActionButton(context); fab.setSize(FloatingActionButton.SIZE_NORMAL); fab.setBackgroundTintList(ColorStateList.valueOf(centreButtonColor)); fab.setImageResource(centreButtonIcon); fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (spaceOnClickListener != null) spaceOnClickListener.onCentreButtonClick(); } }); /** * Set fab layout params */ LayoutParams fabParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); fabParams.addRule(RelativeLayout.CENTER_IN_PARENT); fabParams.setMargins(centreContentMargin, centreContentMargin, centreContentMargin, centreContentMargin); /** * Main content size */ LayoutParams mainContentParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mainContentHeight); mainContentParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); /** * Centre content size */ LayoutParams centreContentParams = new LayoutParams(centreContentWight, spaceNavigationHeight); centreContentParams.addRule(RelativeLayout.CENTER_HORIZONTAL); /** * Centre Background View content size and position */ LayoutParams centreBackgroundViewParams = new LayoutParams(centreContentWight, mainContentHeight); centreBackgroundViewParams.addRule(RelativeLayout.CENTER_HORIZONTAL); centreBackgroundViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); /** * Left content size */ LayoutParams leftContentParams = new LayoutParams(contentWidth, ViewGroup.LayoutParams.MATCH_PARENT); leftContentParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); leftContentParams.addRule(LinearLayout.HORIZONTAL); /** * Right content size */ LayoutParams rightContentParams = new LayoutParams(contentWidth, ViewGroup.LayoutParams.MATCH_PARENT); rightContentParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rightContentParams.addRule(LinearLayout.HORIZONTAL); /** * Adding views background colors */ leftContent.setBackgroundColor(spaceBackgroundColor); rightContent.setBackgroundColor(spaceBackgroundColor); centreBackgroundView.setBackgroundColor(spaceBackgroundColor); /** * Adding view to centreContent */ centreContent.addView(fab, fabParams); /** * Adding views to mainContent */ mainContent.addView(leftContent, leftContentParams); mainContent.addView(rightContent, rightContentParams); /** * Adding views to mainView */ addView(centreBackgroundView, centreBackgroundViewParams); addView(centreContent, centreContentParams); addView(mainContent, mainContentParams); /** * Adding current space items to left and right content */ addSpaceItems(leftContent, rightContent); /** * Redraw main view to make subviews visible */ Utils.postRequestLayout(this); }
From source file:tv.acfun.a63.CommentsActivity.java
public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (ActionBarUtil.hasSB()) { RelativeLayout.LayoutParams params = (LayoutParams) mCommentBar.getLayoutParams(); params.bottomMargin = (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) ? 0 : getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); mCommentBar.setLayoutParams(params); }//from www . j a v a2 s . c o m }
From source file:com.nextgis.mobile.MapFragment.java
public void showInfoPane(boolean isShow) { if (isShow) { mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mChangeLocationListener); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, mChangeLocationListener); mLocationManager.addGpsStatusListener(mGpsStatusListener); final RelativeLayout.LayoutParams RightParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); int nHeight = 0; if (mContext.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { TypedValue typeValue = new TypedValue(); mContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, typeValue, true); nHeight = TypedValue.complexToDimensionPixelSize(typeValue.data, mContext.getResources().getDisplayMetrics()); //getTheme().resolveAttribute(android.R.attr.actionBarSize, typeValue, true); //nHeight = TypedValue.complexToDimensionPixelSize( // typeValue.data,getResources().getDisplayMetrics()); }/* ww w. ja v a 2 s . c om*/ RightParams.setMargins(0, 0, 0, nHeight); mMapRelativeLayout.addView(mInfoPane, RightParams); } else { mLocationManager.removeUpdates(mChangeLocationListener); mLocationManager.removeGpsStatusListener(mGpsStatusListener); mMapRelativeLayout.removeView(mInfoPane); } mIsInfoPaneShow = isShow; }
From source file:com.plusapp.pocketbiceps.app.MainActivity.java
private void showMainTutorial() { // Nimmt das FAB Menue als Target com.github.amlcurran.showcaseview.targets.Target targetFab = new ViewTarget(R.id.fab_menu, this); // Oeffnet das FAB Menue fab_Menu.toggle(true);// ww w . j a v a2s . co m RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); // This aligns button to the bottom left side of screen lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lps.addRule(RelativeLayout.ALIGN_PARENT_LEFT); // Set margins to the button, we add 16dp margins here int margin = ((Number) (getResources().getDisplayMetrics().density * 16)).intValue(); lps.setMargins(margin, margin, margin, margin); // Startet das Tutorial sv = new ShowcaseView.Builder(this).setTarget(targetFab) .setContentTitle(getString(R.string.getting_started)) .setContentText(getString(R.string.getting_started_desc)).setStyle(R.style.CustomShowcaseTheme2) .setOnClickListener(this) // .singleShot(4211) .build(); sv.setButtonText(getString(R.string.next)); // Button wird nach linksunten verschoben sv.setButtonPosition(lps); }