List of usage examples for android.widget RelativeLayout addView
public void addView(View child, int index)
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
/** * Attaches the alarmIcon to all Finds in ListView that currently have an * associated Reminder, which is indicated by the Find's * is_adhoc field being set to REMINDER_SET or REMINDER_NOTIFIED. * /*from w ww .j a va2 s.c o m*/ * @param context -- the context from which this method is called * @param find -- the current Find * @param view -- the calling activity's contentView, which is needed * to access the UI's sub-views. * */ public void listFindCallback(Context context, Find find, View view) { Log.i(TAG, "listFindCallback"); if (find.getIs_adhoc() == REMINDER_SET || find.getIs_adhoc() == this.REMINDER_NOTIFIED) { ImageView alarmIcon = new ImageView(context); alarmIcon.setImageResource(R.drawable.reminder_alarm); RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.list_row_rl); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(25, 25); lp.addRule(RelativeLayout.BELOW, R.id.status); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); lp.setMargins(0, 6, 0, 0); rl.addView(alarmIcon, lp); alarmIcon.setVisibility(ImageView.VISIBLE); } }
From source file:org.borderstone.tagtags.widgets.BGPSWidget.java
public BGPSWidget(Context context, ColumnProperties props, int ROW, int COLUMN) { super(context); setProperties(ROW, COLUMN, props, context); initUI();// w ww.j a v a2 s.c om lblCoordinates = new BInfoLabel(context); String data = Constants.csv.getValue(row, column); if (data.equals("") && props.recurring && props.lastValue != null) { data = props.lastValue; updateData(data); } else if (!data.equals("")) { hasSavedData = true; } lblCoordinates.setText(data); if (properties.gpsGlobal) { lblCoordinates.setGravity(Gravity.CENTER); this.addView(lblCoordinates); } else { RelativeLayout rl = new RelativeLayout(context); RelativeLayout.LayoutParams labelParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams buttonParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); labelParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); buttonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); btnGPS = new ImageButton(context); btnGPS.setBackgroundResource(R.drawable.camera_button); btnGPS.setOnClickListener(this); btnGPS.setOnLongClickListener(this); rl.addView(lblCoordinates, labelParams); rl.addView(btnGPS, buttonParams); updateButtonDrawable(); this.addView(rl); } }
From source file:com.antew.redditinpictures.ui.RedditImageGridFragmentFree.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RelativeLayout v = (RelativeLayout) super.onCreateView(inflater, container, savedInstanceState); mGridView = (GridView) v.findViewById(R.id.gridView); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mHideAds, new IntentFilter(ConstsFree.REMOVE_ADS)); /**/* w w w .java2s.com*/ * If ads are disabled we don't need to load any */ if (!SharedPreferencesHelperFree.getDisableAds(getActivity())) { mAdView = new AdView(getActivity(), AdSize.SMART_BANNER, ConstsFree.ADMOB_ID); /** * The AdView should be attached to the bottom of the screen, with the GridView position above it */ RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); v.addView(mAdView, adParams); /** * We use the onGlobalLayoutListener here in order to adjust the bottom margin of the GridView * so that when the user scrolls to the bottom of the GridView the last images are not obscured * by the AdView */ mAdView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mAdView != null && mGridView != null) { int height = mAdView.getHeight(); if (height > 0) { RelativeLayout.LayoutParams gridViewParams = (RelativeLayout.LayoutParams) mGridView .getLayoutParams(); gridViewParams.setMargins(0, 0, 0, height); mGridView.setLayoutParams(gridViewParams); mAdView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } } }); mAdView.loadAd(AdUtil.getAdRequest()); } return v; }
From source file:es.uma.lcc.lockpic.SelectorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Button btnForward, btnBack, btnFaces; RelativeLayout layout = new RelativeLayout(this); layout.setBackgroundResource(R.drawable.background_gradient); mPath = getIntent().getStringExtra("path"); SelectorActivityBundle bundle = (SelectorActivityBundle) getLastCustomNonConfigurationInstance(); if (bundle != null) { mDrawView = new DrawView(this, mPath, false); mDrawView.setRectangles(bundle.getRectangles()); mDrawView.setViewMode(bundle.getViewMode()); mDrawView.setAspectRate(bundle.getAspectRate()); } else {/*from ww w . ja va 2 s. co m*/ mDrawView = new DrawView(this, mPath, true); } mDrawView.setId(1); RelativeLayout.LayoutParams lpDrawView = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpDrawView.addRule(RelativeLayout.CENTER_VERTICAL); mDrawView.setLayoutParams(lpDrawView); layout.addView(mDrawView, lpDrawView); btnForward = new Button(this); btnForward.setText(R.string.selectorForwardButton); btnForward.setId(2); btnForward.setOnClickListener(new forwardButtonListener()); RelativeLayout.LayoutParams lpButton = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpButton.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lpButton.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layout.addView(btnForward, lpButton); btnBack = new Button(this); btnBack.setText(R.string.selectorBackButton); btnBack.setId(3); btnBack.setOnClickListener(new backButtonListener()); lpButton = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpButton.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lpButton.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layout.addView(btnBack, lpButton); btnFaces = new Button(this); btnFaces.setText(R.string.facesButton); btnFaces.setId(4); btnFaces.setOnClickListener(new FacesButtonListener()); if (!isViewSelectingRegions()) btnFaces.setVisibility(View.INVISIBLE); lpButton = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpButton.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lpButton.addRule(RelativeLayout.CENTER_HORIZONTAL); layout.addView(btnFaces, lpButton); setContentView(layout); }
From source file:io.github.data4all.activity.MapViewActivity.java
private void bodyheightdialog() { PreferenceManager.setDefaultValues(this, R.xml.settings, false); this.prefs = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences userPrefs = getSharedPreferences("UserPrefs", 0); firstUse = userPrefs.getBoolean("firstUse", true); if (firstUse) { RelativeLayout linearLayout = new RelativeLayout(this); final NumberPicker numberPicker = new NumberPicker(this); numberPicker.setMaxValue(250);//from w w w .j av a2 s . c om numberPicker.setMinValue(80); numberPicker.setValue(180); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(50, 50); RelativeLayout.LayoutParams numPicerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); numPicerParams.addRule(RelativeLayout.CENTER_HORIZONTAL); linearLayout.setLayoutParams(params); linearLayout.addView(numberPicker, numPicerParams); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.pref_bodyheight_dialog_title); alertDialogBuilder.setMessage(R.string.pref_bodyheight_dialog_message); alertDialogBuilder.setView(linearLayout); alertDialogBuilder.setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Log.d(TAG, "set bodyheight to: " + numberPicker.getValue()); prefs.edit().putString("PREF_BODY_HEIGHT", String.valueOf(numberPicker.getValue())) .commit(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); // set firstUse to false so this dialog is not shown again. ever. userPrefs.edit().putBoolean("firstUse", false).commit(); firstUse = false; } }
From source file:com.appnexus.opensdkapp.DebugFragment.java
private void createDebugAuctionDialog() { // hacked to be fullscreen with minHeight. see xml RelativeLayout frame = (RelativeLayout) getActivity().getLayoutInflater().inflate(R.layout.dialog_debug, null, false);// w w w . jav a2s .c o m View placeholderView = frame.findViewById(R.id.debug_auction_view); pullToRefreshView = new PullToRefreshWebView(getActivity().getApplicationContext()); WebView webView = pullToRefreshView.getRefreshableView(); webViewClient = new DebugAuctionWebViewClient(webView); webView.setWebViewClient(webViewClient); pullToRefreshView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<WebView>() { @Override public void onRefresh(PullToRefreshBase<WebView> refreshView) { webViewClient.runAuction(); } }); pullToRefreshView.setLayoutParams(placeholderView.getLayoutParams()); // make sure the close button is on top of the webView frame.addView(pullToRefreshView, 1); debugDialog = new AlertDialog.Builder(getActivity()).setView(frame).create(); ImageButton close = (ImageButton) frame.findViewById(R.id.debug_btn_close); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (debugDialog != null) debugDialog.dismiss(); } }); Button email = (Button) frame.findViewById(R.id.debug_btn_email); email.setOnClickListener(emailDebugAuctionOnClickListener); }
From source file:com.frostwire.android.gui.activities.MainActivity2.java
private void updateHeader(Fragment fragment) { try {/* w w w . j av a 2 s . c om*/ RelativeLayout placeholder = (RelativeLayout) getActionBar().getCustomView(); if (placeholder != null && placeholder.getChildCount() > 0) { placeholder.removeAllViews(); } if (fragment instanceof MainFragment) { View header = ((MainFragment) fragment).getHeader(this); if (placeholder != null && header != null) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); placeholder.addView(header, params); } } } catch (Throwable e) { LOG.error("Error updating main header", e); } }
From source file:ti.modules.titanium.ui.widget.TiUIScrollableView.java
private RelativeLayout buildPagingControl(Context context) { RelativeLayout layout = new RelativeLayout(context); layout.setFocusable(false);/*from w ww .j ava 2s . co m*/ layout.setFocusableInTouchMode(false); TiArrowView left = new TiArrowView(context); left.setVisibility(View.INVISIBLE); left.setId(PAGE_LEFT); left.setMinimumWidth(80); // TODO density? left.setMinimumHeight(80); left.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mEnabled) { movePrevious(); } } }); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.CENTER_VERTICAL); layout.addView(left, params); TiArrowView right = new TiArrowView(context); right.setLeft(false); right.setVisibility(View.INVISIBLE); right.setId(PAGE_RIGHT); right.setMinimumWidth(80); // TODO density? right.setMinimumHeight(80); right.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mEnabled) { moveNext(); } } }); params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.CENTER_VERTICAL); layout.addView(right, params); layout.setVisibility(View.GONE); return layout; }
From source file:org.loon.framework.android.game.LGameActivity.java
public void initialization(Bundle icicle, final boolean landscape, final boolean openAD, final LAD lad, final String publisherId, final String keywords, final int requestInterval) { LSystem.gc();// ww w . j ava 2 s . c om this.androidSelect = -2; frameLayout = new FrameLayout(LGameActivity.this); super.onCreate(icicle); if (openAD) { // setVolumeControlStream(AudioManager.STREAM_MUSIC); AdManager.setPublisherId(publisherId); AdManager.setTestDevices(new String[] { "" }); AdManager.setAllowUseOfLocation(true); view = new LGameView(LGameActivity.this, landscape); adview = new AdView(LGameActivity.this); adview.setKeywords(keywords); adview.setRequestInterval(requestInterval); adview.setGravity(Gravity.NO_GRAVITY); RelativeLayout rl = new RelativeLayout(LGameActivity.this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); if (lad == LAD.LEFT) { lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); } else if (lad == LAD.RIGHT) { lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); } else if (lad == LAD.TOP) { lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); } else { lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); } visible = true; adview.requestFreshAd(); frameLayout.addView(view); rl.addView(adview, lp); frameLayout.addView(rl); } else { view = new LGameView(LGameActivity.this, landscape); frameLayout.addView(view); } if (view != null) { gameHandler = view.getGameHandler(); } }
From source file:cn.mailchat.view.PagerSlidingTabStrip.java
private void addIconTab(final int position, int resId) { //layout/*from w w w. jav a 2 s .co m*/ RelativeLayout tabLayout = new RelativeLayout(getContext()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tabLayout.setLayoutParams(layoutParams); tabLayout.setGravity(Gravity.CENTER); //tab RelativeLayout.LayoutParams imgParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); imgParams.addRule(RelativeLayout.CENTER_IN_PARENT); ImageButton tab = new ImageButton(getContext()); tab.setId(100 + position); tab.setImageResource(resId); tabLayout.addView(tab, imgParams); //??? RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId()); View view = new View(getContext()); ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(vParams); tabLayout.addView(view, viewParams); addTab(position, tabLayout); /*BadgeView badgeView = new BadgeView(getContext(), view); badgeView.setText(""); badgeView.setTextSize(10); badgeView.setGravity(Gravity.CENTER); badgeView.setBackgroundResource(R.drawable.main_tab_new_message_notify); badgeView.setBadgePosition(BadgeView.POSITION_VERTICAL_LEFT); badgeView.show();*/ }