List of usage examples for android.widget RelativeLayout ALIGN_PARENT_LEFT
int ALIGN_PARENT_LEFT
To view the source code for android.widget RelativeLayout ALIGN_PARENT_LEFT.
Click Source Link
From source file:im.vector.activity.CallViewActivity.java
/** * Insert the callView in the activity (above the other room member) * @param avatarUrl the other member avatar *///ww w .j a v a2s . c o m private void insertCallView(String avatarUrl) { ImageView avatarView = (ImageView) CallViewActivity.this.findViewById(R.id.call_other_member); avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light); if (!TextUtils.isEmpty(avatarUrl)) { int size = CallViewActivity.this.getResources().getDimensionPixelSize(R.dimen.member_list_avatar_size); mSession.getMediasCache().loadAvatarThumbnail(mSession.getHomeserverConfig(), avatarView, avatarUrl, size); } RelativeLayout layout = (RelativeLayout) CallViewActivity.this.findViewById(R.id.call_layout); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layout.addView(mCallView, 1, params); mCall.setVisibility(View.GONE); }
From source file:com.nextgis.mobile.MapFragment.java
protected void addMapButtons(RelativeLayout rl) { mivZoomIn = new ImageView(getActivity()); mivZoomIn.setImageResource(R.drawable.ic_plus); //mivZoomIn.setId(R.drawable.ic_plus); mivZoomOut = new ImageView(getActivity()); mivZoomOut.setImageResource(R.drawable.ic_minus); //mivZoomOut.setId(R.drawable.ic_minus); final ImageView ivMark = new ImageView(getActivity()); ivMark.setImageResource(R.drawable.ic_mark); //ivMark.setId(R.drawable.ic_mark); //show zoom level between plus and minus mivZoomLevel = new TextView(getActivity()); //ivZoomLevel.setAlpha(150); mivZoomLevel.setId(R.drawable.ic_zoomlevel); final float scale = getResources().getDisplayMetrics().density; int pixels = (int) (48 * scale + 0.5f); mivZoomLevel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); //ivZoomLevel.setTextAppearance(this, android.R.attr.textAppearanceLarge); mivZoomLevel.setWidth(pixels);// ww w .j a va 2 s. co m mivZoomLevel.setHeight(pixels); mivZoomLevel.setTextColor(Color.DKGRAY); mivZoomLevel.setBackgroundColor(Color.argb(50, 128, 128, 128)); //Color.LTGRAY R.drawable.ic_zoomlevel); mivZoomLevel.setGravity(Gravity.CENTER); mivZoomLevel.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mivZoomLevel.setText("" + (int) Math.floor(mMap.getZoomLevel())); mivZoomIn.setOnClickListener(new OnClickListener() { public void onClick(View v) { mMap.zoomIn(); } }); mivZoomOut.setOnClickListener(new OnClickListener() { public void onClick(View v) { mMap.zoomOut(); } }); ivMark.setOnClickListener(new OnClickListener() { public void onClick(View v) { //TODO: onMark(); } }); final RelativeLayout.LayoutParams RightParams1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams1.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); RightParams1.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP rl.addView(mivZoomLevel, RightParams1); final RelativeLayout.LayoutParams RightParams4 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams4.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); RightParams4.addRule(RelativeLayout.ABOVE, R.drawable.ic_zoomlevel);//ALIGN_PARENT_TOP rl.addView(mivZoomIn, RightParams4); final RelativeLayout.LayoutParams RightParams3 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams3.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams3.addRule(RelativeLayout.ALIGN_PARENT_LEFT); RightParams3.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP rl.addView(ivMark, RightParams3); final RelativeLayout.LayoutParams RightParams2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams2.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); RightParams2.addRule(RelativeLayout.BELOW, R.drawable.ic_zoomlevel);//R.drawable.ic_plus); rl.addView(mivZoomOut, RightParams2); setZoomInEnabled(mMap.canZoomIn()); setZoomOutEnabled(mMap.canZoomOut()); }
From source file:com.orangelabs.rcs.ri.messaging.chat.ChatCursorAdapter.java
private void bindChatMessage(Context ctx, Cursor cursor, Direction dir, String displayName, int status, ViewHolderChatMessage holder) {/*from ww w . j av a 2 s . co m*/ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); String mimeType = cursor.getString(holder.columnMimetype); holder.statusText.setText(RiApplication.sMessagesStatuses[status]); String data = cursor.getString(holder.columnContent); holder.chatText.setText(formatDataToText(ctx, mimeType, data)); if (Direction.OUTGOING == dir) { boolean undeliveredExpiration = cursor.getInt(holder.columnExpiredDelivery) == 1; holder.undeliveredIcon.setVisibility(undeliveredExpiration ? View.VISIBLE : View.GONE); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); /* Set background bubble for outgoing */ holder.chatItemLayout.setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.msg_item_left)); holder.contactText.setVisibility(View.GONE); } else { holder.undeliveredIcon.setVisibility(View.GONE); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); /* Set background for incoming */ holder.chatItemLayout.setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.msg_item_right)); if (displayName != null) { holder.contactText.setVisibility(View.VISIBLE); holder.contactText.setText(displayName); } else { holder.contactText.setVisibility(View.GONE); } } holder.chatItemLayout.setLayoutParams(lp); }
From source file:com.adithyaupadhya.uimodule.roundcornerprogressbar.BaseRoundCornerProgressBar.java
private void removeLayoutParamsRule(RelativeLayout.LayoutParams layoutParams) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_END); layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_LEFT); layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_START); } else {//from w w w . j a v a 2 s . co m layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0); } }
From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); dialog = new ProgressDialog(this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentViewLayout = new RelativeLayout(ResourcePlayer.this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); token = prefsPrivate.getString("token", ""); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); Bundle extra = getIntent().getExtras(); if (extra != null) { value = extra.getInt("key"); gooruOID1 = extra.getStringArrayList("goor"); searchkeyword = extra.getString("searchkey"); limit = gooruOID1.size();//w ww . jav a 2 s . c o m gooruOID = gooruOID1.get(value); resourceGooruId = gooruOID; if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) { if (checkInternetConnection()) { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("Please wait while loading..."); dialog.setCancelable(false); dialog.show(); new getResourcesInfo().execute(); } else { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("No internet connection"); dialog.show(); } } } Editor prefsPrivateEditor = prefsPrivate.edit(); // Authentication details prefsPrivateEditor.putString("searchkeyword", searchkeyword); prefsPrivateEditor.commit(); wvPlayer = new WebView(ResourcePlayer.this); wvPlayer.resumeTimers(); wvPlayer.getSettings().setJavaScriptEnabled(true); wvPlayer.getSettings().setPluginState(PluginState.ON); wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); wvPlayer.setWebViewClient(new HelloWebViewClient()); wvPlayer.setWebChromeClient(new MyWebChromeClient() { }); wvPlayer.getSettings().setPluginsEnabled(true); new getResourcesInfo().execute(); RelativeLayout temp = new RelativeLayout(ResourcePlayer.this); temp.setId(668); temp.setBackgroundColor(getResources().getColor(android.R.color.transparent)); header = new RelativeLayout(ResourcePlayer.this); header.setId(1); header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, 53); headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1); ivCloseIcon = new ImageView(ResourcePlayer.this); ivCloseIcon.setId(130); ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50); ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); ivCloseIcon.setPadding(0, 0, 0, 0); ivCloseIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner)); header.addView(ivCloseIcon, ivCloseIconIconParams); ivmoveforward = new ImageView(ResourcePlayer.this); ivmoveforward.setId(222); if (value == limit - 1) { ivmoveforward.setVisibility(View.GONE); } ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0); imageshare = new ImageView(ResourcePlayer.this); imageshare.setId(440); imageshare.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50); imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); imageshareIconParams.setMargins(0, 10, 100, 0); tvDescriptionn = new TextView(ResourcePlayer.this); tvDescriptionn1 = new TextView(ResourcePlayer.this); edittext_copyurl = new EditText(ResourcePlayer.this); imageshare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (desc == 0) { new getShortUrl().execute(); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected)); subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); tvDescriptionn.setVisibility(View.VISIBLE); tvDescriptionn1.setVisibility(View.VISIBLE); edittext_copyurl.setVisibility(View.VISIBLE); tvDescriptionn.setText("Share this with other by copying and pasting these links"); tvDescriptionn.setId(221); tvDescriptionn.setTextSize(18); tvDescriptionn.setTypeface(null, Typeface.BOLD); tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); subheader.addView(tvDescriptionn, tvDescriptionParams); tvDescriptionn1.setText("Collections"); tvDescriptionn1.setId(226); tvDescriptionn1.setTextSize(18); tvDescriptionn1.setTypeface(null, Typeface.BOLD); tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams1.setMargins(20, 42, 0, 20); subheader.addView(tvDescriptionn1, tvDescriptionParams1); edittext_copyurl.setId(266); edittext_copyurl.setTextSize(18); edittext_copyurl.setTypeface(null, Typeface.BOLD); edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams11.setMargins(130, 35, 0, 20); subheader.addView(edittext_copyurl, tvDescriptionParams11); desc = 1; flag = 0; } else { imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); subheader.removeAllViews(); subheader.setVisibility(View.GONE); desc = 0; } } }); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); ivmoveforward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (value < limit - 1) { Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); // extras.putString("gooruOId",s); extras.putStringArrayList("goor", gooruOID1); value++; extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright)); ivmoveback = new ImageView(ResourcePlayer.this); ivmoveback.setId(220); if (value == 0) { ivmoveback.setVisibility(View.GONE); } ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmovebackIconIconParams.setMargins(55, 0, 0, 0); ivmoveback.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!(value <= 0)) { value--; Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); extras.putStringArrayList("goor", gooruOID1); extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left)); webViewBack = new ImageView(ResourcePlayer.this); webViewBack.setId(323); webViewBack.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26); webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewBackIconParams.setMargins(175, 0, 0, 0); webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive)); webViewBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoBack()) { wvPlayer.goBack(); } } }); webViewRefresh = new ImageView(ResourcePlayer.this); webViewRefresh.setId(322); webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30); webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewRefreshIconParams.setMargins(305, 0, 0, 0); webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh)); webViewRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { wvPlayer.reload(); } }); webViewForward = new ImageView(ResourcePlayer.this); webViewForward.setId(321); webViewForward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26); webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParams.setMargins(245, 0, 0, 0); webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive)); webViewForward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoForward()) { wvPlayer.goForward(); } } }); ivResourceIcon = new ImageView(ResourcePlayer.this); ivResourceIcon.setId(30); ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25); ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130); ivResourceIcon.setPadding(50, 0, 0, 0); ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts)); header.addView(ivResourceIcon, ivResourceIconParams); tvLearn = new TextView(this); tvLearn.setText("Learn More"); tvLearn.setId(20); tvLearn.setPadding(100, 0, 0, 0); tvLearn.setTextSize(20); tvLearn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); tvAbout = new ImageView(ResourcePlayer.this); tvAbout.setId(21); tvAbout.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32); webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParamsa.setMargins(0, 0, 200, 0); tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info)); header.addView(tvAbout, webViewForwardIconParamsa); RelativeLayout fortvtitle = new RelativeLayout(this); RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322); tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21); header.addView(fortvtitle, tvTitleParams); tvTitle = new TextView(this); tvTitle.setText(""); tvTitle.setId(22); tvTitle.setPadding(0, 0, 0, 0); tvTitle.setTextSize(25); tvTitle.setSingleLine(true); tvTitle.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1); fortvtitle.addView(tvTitle, tvTitleParamstv); tvViewsNLikes = new TextView(this); tvViewsNLikes.setText(""); tvViewsNLikes.setId(23); tvViewsNLikes.setPadding(0, 0, 5, 5); tvViewsNLikes.setTextSize(18); tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); subheader = new RelativeLayout(ResourcePlayer.this); subheader.setId(100); subheader.setVisibility(View.GONE); subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, 100); subheaderParams.addRule(RelativeLayout.BELOW, 1); subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); wvPlayerParams.addRule(RelativeLayout.BELOW, 100); wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100); LinearLayout videoLayout = new LinearLayout(this); videoLayout.setVisibility(View.GONE); header.addView(webViewBack, webViewBackIconParams); header.addView(webViewRefresh, webViewRefreshIconParams); header.addView(webViewForward, webViewForwardIconParams); header.addView(ivmoveforward, ivmoveforwardIconIconParams); header.addView(imageshare, imageshareIconParams); header.addView(ivmoveback, ivmovebackIconIconParams); temp.addView(header, headerParams); temp.addView(subheader, subheaderParams); temp.addView(wvPlayer, wvPlayerParams); temp.addView(videoLayout, wvPlayerParams); setContentViewLayout.addView(temp, layoutParams); setContentView(setContentViewLayout); tvDescription = new TextView(ResourcePlayer.this); tvDescription1 = new TextView(ResourcePlayer.this); tvAbout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (flag == 0) { subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); // tvDescriptionn.setVisibility(View.INVISIBLE); tvDescription1.setVisibility(View.VISIBLE); tvDescription.setVisibility(View.VISIBLE); tvDescription.setText("Description"); tvDescription.setId(221); tvDescription.setTextSize(18); tvDescription.setTypeface(null, Typeface.BOLD); tvDescription.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); tvDescriptionParams.addRule(RelativeLayout.BELOW, 220); tvDescription1.setText(description); tvDescription1.setLines(3); tvDescription1.setId(321); tvDescription1.setTextSize(15); tvDescription1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100); tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1); tvDescription1.setPadding(100, 20, 100, 0); subheader.addView(tvDescription1, tvDescription1Params); desc = 0; flag = 1; flag1 = 0; } else { subheader.removeAllViews(); subheader.setVisibility(View.GONE); flag = 0; } } }); }
From source file:org.odk.collect.android.widgets.QuestionWidget.java
/** * Default place to put the answer/*from w w w. j a v a 2s . c om*/ * (below the help text or question text if there is no help text) * If you have many elements, use this first * and use the standard addView(view, params) to place the rest */ protected void addAnswerView(View v) { if (v == null) { Timber.e("cannot add a null view as an answerView"); return; } // default place to add answer RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); if (helpTextView.getVisibility() == View.VISIBLE) { params.addRule(RelativeLayout.BELOW, helpTextView.getId()); } else { params.addRule(RelativeLayout.BELOW, questionMediaLayout.getId()); } params.setMargins(10, 0, 10, 0); addView(v, params); }
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 w w w . j av a 2s. co 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:com.frostytornado.cordova.plugin.ad.admob.Util.java
protected void addBannerViewOverlap(String position, String size) { removeBannerViewOverlap();//from www. ja v a 2 s. co m if (bannerViewLayout == null) { bannerViewLayout = new RelativeLayout(plugin.getCordova().getActivity());// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); bannerViewLayout.setLayoutParams(params); ((ViewGroup) getView(plugin.getWebView())).addView(bannerViewLayout); params = new RelativeLayout.LayoutParams(AdView.LayoutParams.WRAP_CONTENT, AdView.LayoutParams.WRAP_CONTENT); if (position.equals("top-left")) { Log.d(LOG_TAG, "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); } bannerView.setLayoutParams(params); bannerViewLayout.addView(bannerView); } }
From source file:org.onebusaway.android.ui.ArrivalsListAdapterStyleB.java
@Override protected void initView(final View view, CombinedArrivalInfoStyleB combinedArrivalInfoStyleB) { final ArrivalInfo stopInfo = combinedArrivalInfoStyleB.getArrivalInfoList().get(0); final ObaArrivalInfo arrivalInfo = stopInfo.getInfo(); final Context context = getContext(); LayoutInflater inflater = LayoutInflater.from(context); TextView routeName = (TextView) view.findViewById(R.id.routeName); TextView destination = (TextView) view.findViewById(R.id.routeDestination); // TableLayout that we will fill with TableRows of arrival times TableLayout arrivalTimesLayout = (TableLayout) view.findViewById(R.id.arrivalTimeLayout); arrivalTimesLayout.removeAllViews(); Resources r = view.getResources(); ImageButton starBtn = (ImageButton) view.findViewById(R.id.route_star); starBtn.setColorFilter(r.getColor(R.color.theme_primary)); ImageButton mapImageBtn = (ImageButton) view.findViewById(R.id.mapImageBtn); mapImageBtn.setColorFilter(r.getColor(R.color.theme_primary)); ImageButton routeMoreInfo = (ImageButton) view.findViewById(R.id.route_more_info); routeMoreInfo.setColorFilter(r.getColor(R.color.switch_thumb_normal_material_dark)); starBtn.setImageResource(/* ww w . j a va2 s.c o m*/ stopInfo.isRouteAndHeadsignFavorite() ? R.drawable.focus_star_on : R.drawable.focus_star_off); starBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Show dialog for setting route favorite RouteFavoriteDialogFragment dialog = new RouteFavoriteDialogFragment.Builder( stopInfo.getInfo().getRouteId(), stopInfo.getInfo().getHeadsign()) .setRouteShortName(stopInfo.getInfo().getShortName()) .setRouteLongName(stopInfo.getInfo().getRouteLongName()) .setStopId(stopInfo.getInfo().getStopId()) .setFavorite(!stopInfo.isRouteAndHeadsignFavorite()).build(); dialog.setCallback(new RouteFavoriteDialogFragment.Callback() { @Override public void onSelectionComplete(boolean savedFavorite) { if (savedFavorite) { mFragment.refreshLocal(); } } }); dialog.show(mFragment.getFragmentManager(), RouteFavoriteDialogFragment.TAG); } }); // Setup map mapImageBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showRouteOnMap(stopInfo); } }); // Setup more routeMoreInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showListItemMenu(view, stopInfo); } }); routeName.setText(arrivalInfo.getShortName()); destination.setText(MyTextUtils.toTitleCase(arrivalInfo.getHeadsign())); // Loop through the arrival times and create the TableRows that contains the data for (int i = 0; i < combinedArrivalInfoStyleB.getArrivalInfoList().size(); i++) { final ArrivalInfo arrivalRow = combinedArrivalInfoStyleB.getArrivalInfoList().get(i); final ObaArrivalInfo tempArrivalInfo = arrivalRow.getInfo(); long scheduledTime = tempArrivalInfo.getScheduledArrivalTime(); // Create a new row to be added final TableRow tr = (TableRow) inflater.inflate(R.layout.arrivals_list_tr_template_style_b, null); // Layout and views to inflate from XML templates RelativeLayout layout; TextView scheduleView, estimatedView, statusView; View divider; if (i == 0) { // Use larger styled layout/view for next arrival time layout = (RelativeLayout) inflater.inflate(R.layout.arrivals_list_rl_template_style_b_large, null); scheduleView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_schedule_large, null); estimatedView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_estimated_large, null); statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_large, null); } else { // Use smaller styled layout/view for further out times layout = (RelativeLayout) inflater.inflate(R.layout.arrivals_list_rl_template_style_b_small, null); scheduleView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_schedule_small, null); estimatedView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_estimated_small, null); statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_small, null); } // Set arrival times and status in views scheduleView.setText(DateUtils.formatDateTime(context, scheduledTime, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT)); if (arrivalRow.getPredicted()) { long eta = arrivalRow.getEta(); if (eta == 0) { estimatedView.setText(R.string.stop_info_eta_now); } else { estimatedView.setText(eta + " min"); } } else { estimatedView.setText(R.string.stop_info_eta_unknown); } statusView.setText(arrivalRow.getStatusText()); int colorCode = arrivalRow.getColor(); statusView.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) statusView.getBackground(); d.setColor(context.getResources().getColor(colorCode)); int alpha; if (i == 0) { // Set next arrival alpha = (int) (1.0f * 255); // X percent transparency } else { // Set smaller rows alpha = (int) (.35f * 255); // X percent transparency } d.setAlpha(alpha); // Set padding on status view int pSides = UIUtils.dpToPixels(context, 5); int pTopBottom = UIUtils.dpToPixels(context, 2); statusView.setPadding(pSides, pTopBottom, pSides, pTopBottom); // Add TextViews to layout layout.addView(scheduleView); layout.addView(statusView); layout.addView(estimatedView); // Make sure the TextViews align left/center/right of parent relative layout RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) scheduleView.getLayoutParams(); params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params1.addRule(RelativeLayout.CENTER_VERTICAL); scheduleView.setLayoutParams(params1); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) statusView.getLayoutParams(); params2.addRule(RelativeLayout.CENTER_IN_PARENT); // Give status view a little extra margin int p = UIUtils.dpToPixels(context, 3); params2.setMargins(p, p, p, p); statusView.setLayoutParams(params2); RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams) estimatedView.getLayoutParams(); params3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params3.addRule(RelativeLayout.CENTER_VERTICAL); estimatedView.setLayoutParams(params3); // Add layout to TableRow tr.addView(layout); // Add the divider, if its not the first row if (i != 0) { int dividerHeight = UIUtils.dpToPixels(context, 1); divider = inflater.inflate(R.layout.arrivals_list_divider_template_style_b, null); divider.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, dividerHeight)); arrivalTimesLayout.addView(divider); } // Add click listener tr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showListItemMenu(tr, arrivalRow); } }); // Add TableRow to container layout arrivalTimesLayout.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); } // Show or hide reminder for this trip ContentValues values = null; if (mTripsForStop != null) { values = mTripsForStop.getValues(arrivalInfo.getTripId()); } if (values != null) { String reminderName = values.getAsString(ObaContract.Trips.NAME); TextView reminder = (TextView) view.findViewById(R.id.reminder); if (reminderName.length() == 0) { reminderName = context.getString(R.string.trip_info_noname); } reminder.setText(reminderName); Drawable d = reminder.getCompoundDrawables()[0]; d = DrawableCompat.wrap(d); DrawableCompat.setTint(d.mutate(), view.getResources().getColor(R.color.theme_primary)); reminder.setCompoundDrawables(d, null, null, null); reminder.setVisibility(View.VISIBLE); } else { // Explicitly set reminder to invisible because we might be reusing // this view. View reminder = view.findViewById(R.id.reminder); reminder.setVisibility(View.GONE); } }
From source file:de.mrapp.android.dialog.decorator.MaterialDialogDecorator.java
/** * Creates and returns the layout params, which should be used by the dialog's root view. * * @return The layout params, which have been created, as an instance of the class {@link * RelativeLayout.LayoutParams}//from ww w. ja v a 2s . co m */ private RelativeLayout.LayoutParams createLayoutParams() { Rect windowDimensions = new Rect(); Window window = getWindow(); assert window != null; window.getDecorView().getWindowVisibleDisplayFrame(windowDimensions); int shadowWidth = isFullscreen() ? 0 : getContext().getResources().getDimensionPixelSize(R.dimen.dialog_shadow_width); int leftInset = isFitsSystemWindowsLeft() && isFullscreen() && windowInsets != null ? windowInsets.left : 0; int topInset = isFitsSystemWindowsTop() && isFullscreen() && windowInsets != null ? windowInsets.top : 0; int rightInset = isFitsSystemWindowsRight() && isFullscreen() && windowInsets != null ? windowInsets.right : 0; int bottomInset = isFitsSystemWindowsBottom() && isFullscreen() && windowInsets != null ? windowInsets.bottom : 0; int leftMargin = getLeftMargin() - shadowWidth + leftInset; int topMargin = getTopMargin() - shadowWidth + topInset; int rightMargin = getRightMargin() - shadowWidth + rightInset; int bottomMargin = getBottomMargin() - shadowWidth + bottomInset; int width = getLayoutDimension(getWidth(), leftMargin + rightMargin, windowDimensions.right); int height = getLayoutDimension(getHeight(), topMargin + bottomMargin, windowDimensions.bottom); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height); layoutParams.leftMargin = leftMargin; layoutParams.topMargin = topMargin; layoutParams.rightMargin = rightMargin; layoutParams.bottomMargin = bottomMargin; if ((getGravity() & Gravity.CENTER_HORIZONTAL) == Gravity.CENTER_HORIZONTAL) { layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); } if ((getGravity() & Gravity.CENTER_VERTICAL) == Gravity.CENTER_VERTICAL) { layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); } if ((getGravity() & Gravity.LEFT) == Gravity.LEFT) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); } if ((getGravity() & Gravity.TOP) == Gravity.TOP) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } if ((getGravity() & Gravity.RIGHT) == Gravity.RIGHT) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); } if ((getGravity() & Gravity.BOTTOM) == Gravity.BOTTOM) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); } return layoutParams; }