List of usage examples for android.widget RelativeLayout CENTER_HORIZONTAL
int CENTER_HORIZONTAL
To view the source code for android.widget RelativeLayout CENTER_HORIZONTAL.
Click Source Link
From source file:busradar.madison.StopDialog.java
StopDialog(final Context ctx, final int stopid, final int lat, final int lon) { super(ctx);//from w w w . j a va2 s .c o m this.stopid = stopid; // getWindow().requestFeature(Window.FEATURE_LEFT_ICON); getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final String name = DB.getStopName(stopid); setTitle(name); routes = get_time_urls(StopDialog.this.stopid); // getWindow().setLayout(LayoutParams.FILL_PARENT, // LayoutParams.FILL_PARENT); setContentView(new RelativeLayout(ctx) { { addView(new TextView(ctx) { { setId(stop_num_id); setText(Html.fromHtml(String.format( "[<a href='http://www.cityofmadison.com/metro/BusStopDepartures/StopID/%04d.pdf'>%04d</a>]", stopid, stopid))); setPadding(0, 0, 5, 0); this.setMovementMethod(LinkMovementMethod.getInstance()); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(ALIGN_PARENT_RIGHT); } }); addView(new ImageView(ctx) { boolean enabled; @Override public void setEnabled(boolean e) { enabled = e; setImageResource(e ? R.drawable.love_enabled : R.drawable.love_disabled); if (e) { G.favorites.add_favorite_stop(stopid, name, lat, lon); Toast.makeText(ctx, "Added stop to Favorites", Toast.LENGTH_SHORT).show(); } else { G.favorites.remove_favorite_stop(stopid); Toast.makeText(ctx, "Removed stop from Favorites", Toast.LENGTH_SHORT).show(); } } { enabled = G.favorites.is_stop_favorite(stopid); setImageResource(enabled ? R.drawable.love_enabled : R.drawable.love_disabled); setPadding(0, 0, 10, 0); setOnClickListener(new OnClickListener() { public void onClick(View v) { setEnabled(!enabled); } }); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(LEFT_OF, stop_num_id); setMargins(0, -3, 0, 0); } }); addView(cur_loading_text = new TextView(ctx) { { setText("Loading..."); setPadding(5, 0, 0, 0); } }); addView(new HorizontalScrollView(ctx) { { setId(route_list_id); setHorizontalScrollBarEnabled(false); addView(new LinearLayout(ctx) { float text_size; Button cur_button; { int last_route = -1; for (int i = 0; i < routes.length; i++) { final RouteURL route = routes[i]; if (route.route == last_route) continue; last_route = route.route; addView(new Button(ctx) { public void setEnabled(boolean e) { if (e) { setBackgroundColor(0xff000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size * 1.5f); } else { setBackgroundColor(0x90000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size); } } { setText(G.route_points[route.route].name); setTextColor(0xffffffff); setTypeface(Typeface.DEFAULT_BOLD); text_size = getTextSize(); if (G.active_route == route.route) { setEnabled(true); cur_button = this; } else setEnabled(false); final Button b = this; setOnClickListener(new OnClickListener() { public void onClick(View v) { if (cur_button != null) { cur_button.setEnabled(false); } if (cur_button == b) { cur_button.setEnabled(false); cur_button = null; selected_route = null; update_time_display(); } else { cur_button = b; cur_button.setEnabled(true); selected_route = route; update_time_display(); } } }); } }); } } }); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, stop_num_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(status_text = new TextView(ctx) { { setText(""); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, route_list_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(list_view = new ListView(ctx) { { setId(time_list_id); setVerticalScrollBarEnabled(false); setAdapter(times_adapter = new BaseAdapter() { public View getView(final int position, View convertView, ViewGroup parent) { CellView v; if (convertView == null) v = new CellView(ctx); else v = (CellView) convertView; RouteTime rt = curr_times.get(position); v.setBackgroundColor(G.route_points[rt.route].color | 0xff000000); v.route_textview.setText(G.route_points[rt.route].name); if (rt.dir != null) v.dir_textview.setText("to " + rt.dir); v.time_textview.setText(rt.time); return v; } public int getCount() { return curr_times.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } }); } }, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) { { addRule(RelativeLayout.BELOW, route_list_id); } }); } }); TextView title = (TextView) findViewById(android.R.id.title); title.setEllipsize(TextUtils.TruncateAt.MARQUEE); title.setSelected(true); title.setTextColor(0xffffffff); title.setMarqueeRepeatLimit(-1); // getWindow().set, value) // getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, // android.R.drawable.ic_dialog_info); // title.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL); if (G.active_route >= 0) for (int i = 0; i < routes.length; i++) if (routes[i].route == G.active_route) { selected_route = routes[i]; RouteURL[] rnew = new RouteURL[routes.length]; rnew[0] = selected_route; for (int j = 0, k = 1; j < routes.length; j++) if (j != i) rnew[k++] = routes[j]; routes = rnew; break; } update_time_display(); }
From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
@SuppressLint("NewApi") private static void applyAttributes(View view, Map<String, String> attrs, ViewGroup parent) { if (viewRunnables == null) createViewRunnables();/*from ww w . j a v a 2 s .c om*/ ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); int layoutRule; int marginLeft = 0, marginRight = 0, marginTop = 0, marginBottom = 0, paddingLeft = 0, paddingRight = 0, paddingTop = 0, paddingBottom = 0; boolean hasCornerRadius = false, hasCornerRadii = false; for (Map.Entry<String, String> entry : attrs.entrySet()) { String attr = entry.getKey(); if (viewRunnables.containsKey(attr)) { viewRunnables.get(attr).apply(view, entry.getValue(), parent, attrs); continue; } if (attr.startsWith("cornerRadius")) { hasCornerRadius = true; hasCornerRadii = !attr.equals("cornerRadius"); continue; } layoutRule = NO_LAYOUT_RULE; boolean layoutTarget = false; switch (attr) { case "id": String idValue = parseId(entry.getValue()); if (parent != null) { DynamicLayoutInfo info = getDynamicLayoutInfo(parent); int newId = highestIdNumberUsed++; view.setId(newId); info.nameToIdNumber.put(idValue, newId); } break; case "width": case "layout_width": switch (entry.getValue()) { case "wrap_content": layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; break; case "fill_parent": case "match_parent": layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; break; default: layoutParams.width = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics(), parent, true); break; } break; case "height": case "layout_height": switch (entry.getValue()) { case "wrap_content": layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; break; case "fill_parent": case "match_parent": layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; break; default: layoutParams.height = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics(), parent, false); break; } break; case "layout_gravity": if (parent != null && parent instanceof LinearLayout) { ((LinearLayout.LayoutParams) layoutParams).gravity = parseGravity(entry.getValue()); } else if (parent != null && parent instanceof FrameLayout) { ((FrameLayout.LayoutParams) layoutParams).gravity = parseGravity(entry.getValue()); } break; case "layout_weight": if (parent != null && parent instanceof LinearLayout) { ((LinearLayout.LayoutParams) layoutParams).weight = Float.parseFloat(entry.getValue()); } break; case "layout_below": layoutRule = RelativeLayout.BELOW; layoutTarget = true; break; case "layout_above": layoutRule = RelativeLayout.ABOVE; layoutTarget = true; break; case "layout_toLeftOf": layoutRule = RelativeLayout.LEFT_OF; layoutTarget = true; break; case "layout_toRightOf": layoutRule = RelativeLayout.RIGHT_OF; layoutTarget = true; break; case "layout_alignBottom": layoutRule = RelativeLayout.ALIGN_BOTTOM; layoutTarget = true; break; case "layout_alignTop": layoutRule = RelativeLayout.ALIGN_TOP; layoutTarget = true; break; case "layout_alignLeft": case "layout_alignStart": layoutRule = RelativeLayout.ALIGN_LEFT; layoutTarget = true; break; case "layout_alignRight": case "layout_alignEnd": layoutRule = RelativeLayout.ALIGN_RIGHT; layoutTarget = true; break; case "layout_alignParentBottom": layoutRule = RelativeLayout.ALIGN_PARENT_BOTTOM; break; case "layout_alignParentTop": layoutRule = RelativeLayout.ALIGN_PARENT_TOP; break; case "layout_alignParentLeft": case "layout_alignParentStart": layoutRule = RelativeLayout.ALIGN_PARENT_LEFT; break; case "layout_alignParentRight": case "layout_alignParentEnd": layoutRule = RelativeLayout.ALIGN_PARENT_RIGHT; break; case "layout_centerHorizontal": layoutRule = RelativeLayout.CENTER_HORIZONTAL; break; case "layout_centerVertical": layoutRule = RelativeLayout.CENTER_VERTICAL; break; case "layout_centerInParent": layoutRule = RelativeLayout.CENTER_IN_PARENT; break; case "layout_margin": marginLeft = marginRight = marginTop = marginBottom = DimensionConverter .stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics()); break; case "layout_marginLeft": marginLeft = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics(), parent, true); break; case "layout_marginTop": marginTop = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics(), parent, false); break; case "layout_marginRight": marginRight = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics(), parent, true); break; case "layout_marginBottom": marginBottom = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics(), parent, false); break; case "padding": paddingBottom = paddingLeft = paddingRight = paddingTop = DimensionConverter .stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics()); break; case "paddingLeft": paddingLeft = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics()); break; case "paddingTop": paddingTop = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics()); break; case "paddingRight": paddingRight = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics()); break; case "paddingBottom": paddingBottom = DimensionConverter.stringToDimensionPixelSize(entry.getValue(), view.getResources().getDisplayMetrics()); break; } if (layoutRule != NO_LAYOUT_RULE && parent instanceof RelativeLayout) { if (layoutTarget) { int anchor = idNumFromIdString(parent, parseId(entry.getValue())); ((RelativeLayout.LayoutParams) layoutParams).addRule(layoutRule, anchor); } else if (entry.getValue().equals("true")) { ((RelativeLayout.LayoutParams) layoutParams).addRule(layoutRule); } } } // TODO: this is a giant mess; come up with a simpler way of deciding what to draw for the background if (attrs.containsKey("background") || attrs.containsKey("borderColor")) { String bgValue = attrs.containsKey("background") ? attrs.get("background") : null; if (bgValue != null && bgValue.startsWith("@drawable/")) { view.setBackground(getDrawableByName(view, bgValue)); } else if (bgValue == null || bgValue.startsWith("#") || bgValue.startsWith("@color")) { if (view instanceof Button || attrs.containsKey("pressedColor")) { int bgColor = parseColor(view, bgValue == null ? "#00000000" : bgValue); int pressedColor; if (attrs.containsKey("pressedColor")) { pressedColor = parseColor(view, attrs.get("pressedColor")); } else { pressedColor = adjustBrightness(bgColor, 0.9f); } GradientDrawable gd = new GradientDrawable(); gd.setColor(bgColor); GradientDrawable pressedGd = new GradientDrawable(); pressedGd.setColor(pressedColor); if (hasCornerRadii) { float radii[] = new float[8]; for (int i = 0; i < CORNERS.length; i++) { String corner = CORNERS[i]; if (attrs.containsKey("cornerRadius" + corner)) { radii[i * 2] = radii[i * 2 + 1] = DimensionConverter.stringToDimension( attrs.get("cornerRadius" + corner), view.getResources().getDisplayMetrics()); } gd.setCornerRadii(radii); pressedGd.setCornerRadii(radii); } } else if (hasCornerRadius) { float cornerRadius = DimensionConverter.stringToDimension(attrs.get("cornerRadius"), view.getResources().getDisplayMetrics()); gd.setCornerRadius(cornerRadius); pressedGd.setCornerRadius(cornerRadius); } if (attrs.containsKey("borderColor")) { String borderWidth = "1dp"; if (attrs.containsKey("borderWidth")) { borderWidth = attrs.get("borderWidth"); } int borderWidthPx = DimensionConverter.stringToDimensionPixelSize(borderWidth, view.getResources().getDisplayMetrics()); gd.setStroke(borderWidthPx, parseColor(view, attrs.get("borderColor"))); pressedGd.setStroke(borderWidthPx, parseColor(view, attrs.get("borderColor"))); } StateListDrawable selector = new StateListDrawable(); selector.addState(new int[] { android.R.attr.state_pressed }, pressedGd); selector.addState(new int[] {}, gd); view.setBackground(selector); getDynamicLayoutInfo(view).bgDrawable = gd; } else if (hasCornerRadius || attrs.containsKey("borderColor")) { GradientDrawable gd = new GradientDrawable(); int bgColor = parseColor(view, bgValue == null ? "#00000000" : bgValue); gd.setColor(bgColor); if (hasCornerRadii) { float radii[] = new float[8]; for (int i = 0; i < CORNERS.length; i++) { String corner = CORNERS[i]; if (attrs.containsKey("cornerRadius" + corner)) { radii[i * 2] = radii[i * 2 + 1] = DimensionConverter.stringToDimension( attrs.get("cornerRadius" + corner), view.getResources().getDisplayMetrics()); } gd.setCornerRadii(radii); } } else if (hasCornerRadius) { float cornerRadius = DimensionConverter.stringToDimension(attrs.get("cornerRadius"), view.getResources().getDisplayMetrics()); gd.setCornerRadius(cornerRadius); } if (attrs.containsKey("borderColor")) { String borderWidth = "1dp"; if (attrs.containsKey("borderWidth")) { borderWidth = attrs.get("borderWidth"); } gd.setStroke( DimensionConverter.stringToDimensionPixelSize(borderWidth, view.getResources().getDisplayMetrics()), parseColor(view, attrs.get("borderColor"))); } view.setBackground(gd); getDynamicLayoutInfo(view).bgDrawable = gd; } else { view.setBackgroundColor(parseColor(view, bgValue)); } } } if (layoutParams instanceof ViewGroup.MarginLayoutParams) { ((ViewGroup.MarginLayoutParams) layoutParams).setMargins(marginLeft, marginTop, marginRight, marginBottom); } view.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); view.setLayoutParams(layoutParams); }
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);// w w w.jav a 2 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.cricketkorner.cricket.VitamioListActivity.java
/** * Part of the activity's life cycle, StartAppAd should be integrated here * for the back button exit ad integration. *//*from ww w . j a v a 2 s . c o m*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); myData = new ArrayList<Map<String, Object>>(); StartAppSDK.init(this, "106556515", "206801872"); startAppAd = new StartAppAd(this); // relativeLayout = (RelativeLayout)findViewById(R.id.channelLayout); /** Create Splash Ad **/ StartAppAd.showSplash(this, savedInstanceState, new SplashConfig().setTheme(Theme.OCEAN) .setLogo(R.drawable.ic_launcher).setAppName("Cricket Korner!")); setContentView(R.layout.channel_list); StartAppAd.showSlider(this); title = new ArrayList<String>(); desc = new ArrayList<String>(); thumb = new ArrayList<Integer>(); RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.channelLayout); // Create new StartApp banner Banner startAppBanner = new Banner(this); RelativeLayout.LayoutParams bannerParameters = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); bannerParameters.addRule(RelativeLayout.CENTER_HORIZONTAL); bannerParameters.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); // Add the banner to the main layout mainLayout.addView(startAppBanner, bannerParameters); if (!LibsChecker.checkVitamioLibs(this)) return; if (isNetworkAvailable()) { new ServerHitLinks().execute("http://ahmadshahwaiz.com/LiveStreaming/getLinks.php"); } else { Toast.makeText(getApplicationContext(), "Please Connect With Internet", Toast.LENGTH_LONG).show(); finish(); finish(); } }
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);//from ww w . j a v a 2s . c om 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:com.cranberrygame.phonegap.plugin.ad.Util.java
private void _showBannerAd(String position, String size) { this.position = position; this.size = size; if (bannerAdPreloaded) { bannerAdPreloaded = false;/*from w ww .j a va 2s.c om*/ } 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:lemonlabs.android.expandablebuttonmenu.ExpandableButtonMenu.java
/** * Manually invalidate views for pre-Honeycomb devices *///from w w w . ja v a2s . 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.cranberrygame.cordova.plugin.ad.admob.Util.java
private void _showBannerAd_overlap(String position, String size) { //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(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 {//w ww. j av a 2 s .co m params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } //bannerViewLayout.addView(bannerView, params); bannerView.setLayoutParams(params); bannerViewLayout.addView(bannerView); }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * It contains a list view to display custom servers, * "Add" button to add custom server, "Delete" button to delete custom server. * The custom servers would be saved in customServers.xml. If click a list item, it would be saved as current server. * // ww w .j av a 2 s .c om * @return the linear layout */ private LinearLayout constructCustomServersView() { LinearLayout custumeView = new LinearLayout(this); custumeView.setOrientation(LinearLayout.VERTICAL); custumeView.setPadding(20, 5, 5, 0); custumeView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); ArrayList<String> customServers = new ArrayList<String>(); initCustomServersFromFile(customServers); RelativeLayout buttonsView = new RelativeLayout(this); buttonsView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 80)); Button addServer = new Button(this); addServer.setWidth(80); RelativeLayout.LayoutParams addServerLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); addServerLayout.addRule(RelativeLayout.CENTER_HORIZONTAL); addServer.setLayoutParams(addServerLayout); addServer.setText("Add"); addServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setClass(AppSettingsActivity.this, AddServerActivity.class); startActivityForResult(intent, Constants.REQUEST_CODE); } }); Button deleteServer = new Button(this); deleteServer.setWidth(80); RelativeLayout.LayoutParams deleteServerLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); deleteServerLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); deleteServer.setLayoutParams(deleteServerLayout); deleteServer.setText("Delete"); deleteServer.setOnClickListener(new OnClickListener() { @SuppressWarnings("unchecked") public void onClick(View v) { int checkedPosition = customListView.getCheckedItemPosition(); if (!(checkedPosition == ListView.INVALID_POSITION)) { customListView.setItemChecked(checkedPosition, false); ((ArrayAdapter<String>) customListView.getAdapter()) .remove(customListView.getItemAtPosition(checkedPosition).toString()); currentServer = ""; AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); writeCustomServerToFile(); } } }); buttonsView.addView(addServer); buttonsView.addView(deleteServer); customListView = new ListView(this); customListView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200)); customListView.setCacheColorHint(0); final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(), R.layout.server_list_item, customServers); customListView.setAdapter(serverListAdapter); customListView.setItemsCanFocus(true); customListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); if (currentCustomServerIndex != -1) { customListView.setItemChecked(currentCustomServerIndex, true); currentServer = (String) customListView.getItemAtPosition(currentCustomServerIndex); } customListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { currentServer = (String) parent.getItemAtPosition(position); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); writeCustomServerToFile(); requestPanelList(); checkAuthentication(); requestAccess(); } }); custumeView.addView(customListView); custumeView.addView(buttonsView); requestPanelList(); checkAuthentication(); requestAccess(); return custumeView; }
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();//from w w w. j a va 2 s . c om 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; } } }); }