List of usage examples for android.widget RelativeLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java
public void createMessage(ViewGroup l, String text, String button, View.OnClickListener onclick) { RelativeLayout r = new RelativeLayout(getActivity()); r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); LinearLayout l2 = new LinearLayout(getActivity()); l2.setOrientation(LinearLayout.VERTICAL); RelativeLayout.LayoutParams layoutparams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutparams.addRule(RelativeLayout.CENTER_VERTICAL); l2.setLayoutParams(layoutparams);/*from w w w .ja va 2s . com*/ l2.setGravity(Gravity.CENTER_HORIZONTAL); TextView tv = new TextView(getActivity()); LinearLayout.LayoutParams tvparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tv.setLayoutParams(tvparams); tv.setText(text); tv.setTextSize(23); tv.setPadding(0, 0, 0, toPixels(15)); l2.addView(tv); if (button != null) { Button b = new Button(getActivity()); LinearLayout.LayoutParams bparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); bparams.setMargins(toPixels(4), toPixels(0), toPixels(4), toPixels(4)); b.setLayoutParams(bparams); b.setId(R.id.reload_button); b.setText(button); b.setTextSize(23); b.setAllCaps(false); b.setTypeface(null, Typeface.NORMAL); b.setOnClickListener(onclick); l2.addView(b); } r.addView(l2); l.addView(r); }
From source file:ru.jango.j0widget.camera.fragment.AbstractCameraFragment.java
private RelativeLayout createRelativeLayout() { final RelativeLayout layout = new RelativeLayout(getActivity()); layout.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); layout.setBackgroundColor(Color.BLACK); return layout; }
From source file:org.disrupted.rumble.userinterface.activity.HomeActivity.java
public View renderTabView(Context context, int iconResource) { RelativeLayout view = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.badge_tab_layout, null);//www.j av a 2 s. com view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ((ImageView) view.findViewById(R.id.tab_icon)).setImageResource(iconResource); ((TextView) view.findViewById(R.id.tab_badge)).setVisibility(View.INVISIBLE); return view; }
From source file:it.meet.activities.MainActivity.java
/** * When using the ActionBarDrawerToggle, you must call it during * onPostCreate() and onConfigurationChanged()... */// w w w .j av a 2s.com @Override public void onBackPressed() { if (currentFragment instanceof ChatFragment) { if (((ChatFragment) currentFragment).getPopupWindow().isShowing()) { ((ChatFragment) currentFragment).getPopupWindow().dismiss(); FrameLayout.LayoutParams baseChatLayoutParams = new FrameLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); RelativeLayout baseChatLayout = (RelativeLayout) findViewById(R.id.base_chat_layout2); baseChatLayout.setLayoutParams(baseChatLayoutParams); } else { this.selectItem(1); } } else if (currentFragment instanceof FriendProfileFragment) { this.selectItem(2); } else if (currentFragment instanceof ConversationsListFragment || currentFragment instanceof FriendsListFragment || currentFragment instanceof BlackListFragment || currentFragment instanceof FavoritePlacesFragment || currentFragment instanceof FriendRequestsFragment || currentFragment instanceof MyProfileFragment || currentFragment instanceof SettingsFragment || currentFragment instanceof SearchFragment) { askExit(); } else { finish(); } }
From source file:com.githang.androidkit.app.IntroActivity.java
/** * /*w w w .j a v a 2 s . c o m*/ */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java
/** * /*from w w w . j a v a 2 s.c o m*/ */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:com.openlocationcode.android.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_act);/*from w w w . jav a 2 s .c o m*/ MyMapView myMapView = (MyMapView) findViewById(R.id.myMapView); mMapView = myMapView.getMapView(); mMainPresenter = new MainPresenter(this, (SearchView) findViewById(R.id.searchView), (DirectionView) findViewById(R.id.directionView), (CodeView) findViewById(R.id.codeView), myMapView); mMapView.onCreate(savedInstanceState); // Adjust the map controls and search box top margins to account for the translucent status // bar. int statusBarHeight = getStatusBarHeight(this); LinearLayout mapControl = (LinearLayout) findViewById(R.id.mapControls); FrameLayout.LayoutParams mapParams = (FrameLayout.LayoutParams) mapControl.getLayoutParams(); mapParams.topMargin = mapParams.topMargin + statusBarHeight; mapControl.setLayoutParams(mapParams); RelativeLayout searchBox = (RelativeLayout) findViewById(R.id.searchBox); FrameLayout.LayoutParams searchParams = (FrameLayout.LayoutParams) searchBox.getLayoutParams(); searchParams.topMargin = searchParams.topMargin + statusBarHeight; searchBox.setLayoutParams(searchParams); if (getIntent() != null && Intent.ACTION_VIEW.equals(getIntent().getAction())) { handleGeoIntent(getIntent()); } }
From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java
/** * ???/*from ww w . jav a 2 s .com*/ * @param horizontalGravity ?? * @param verticalGravity ?? * @return */ protected RelativeLayout createToolbarLayout(int horizontalGravity, int verticalGravity) { RelativeLayout toolbarLayOut = new RelativeLayout(mContext); toolbarLayOut.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, dpToPixels(44))); toolbarLayOut.setPadding(dpToPixels(2), dpToPixels(2), dpToPixels(2), dpToPixels(2)); toolbarLayOut.setHorizontalGravity(horizontalGravity); toolbarLayOut.setVerticalGravity(verticalGravity); return toolbarLayOut; }
From source file:com.derrick.movies.MovieDetailsActivity.java
private void setTrailers(Videos videos) { videosList = videos.getResults();/*from ww w. j a v a2s. c om*/ 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.polyvi.xface.extension.inappbrowser.XInAppBrowser.java
/** * ??button//w w w.j a v a 2 s . c o m * @param containerId id? * @param params ? * @param horizontalGravity ?? * @param verticalGravity ?? * @return */ protected RelativeLayout createActionButtonContainer(int containerId, RelativeLayout.LayoutParams params, int horizontalGravity, int verticalGravity) { RelativeLayout actionButtonContainer = new RelativeLayout(mContext); actionButtonContainer.setLayoutParams(params); actionButtonContainer.setHorizontalGravity(horizontalGravity); actionButtonContainer.setVerticalGravity(verticalGravity); actionButtonContainer.setId(containerId); return actionButtonContainer; }