List of usage examples for android.widget FrameLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.example.angelina.travelapp.map.MapActivity.java
/** * Show the list of directions/* www .j ava 2s. co m*/ * @param directions List of DirectionManeuver items containing navigation directions */ public final void showDirections(final List<DirectionManeuver> directions) { final FragmentManager fm = getSupportFragmentManager(); RouteDirectionsFragment routeDirectionsFragment = (RouteDirectionsFragment) fm .findFragmentById(R.id.route_directions_container); if (routeDirectionsFragment == null) { routeDirectionsFragment = RouteDirectionsFragment.newInstance(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), routeDirectionsFragment, R.id.route_directions_container, getString(R.string.route_fragment)); } // Show the fragment final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.requestLayout(); // Hide the map final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(0, 0); layoutParams.setMargins(0, 0, 0, 0); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); routeDirectionsFragment.setRoutingDirections(directions); }
From source file:gr.plushost.prototypeapp.widgets.LabelView.java
private boolean replaceLayout(View target) { if (getParent() != null || target == null || target.getParent() == null || _labelViewContainerID != -1) { return false; }//from w w w.ja v a 2s.co m ViewGroup parentContainer = (ViewGroup) target.getParent(); if (target.getParent() instanceof FrameLayout) { ((FrameLayout) target.getParent()).addView(this); } else if (target.getParent() instanceof ViewGroup) { int groupIndex = parentContainer.indexOfChild(target); _labelViewContainerID = generateViewId(); // relativeLayout need copy rule if (target.getParent() instanceof RelativeLayout) { for (int i = 0; i < parentContainer.getChildCount(); i++) { if (i == groupIndex) { continue; } View view = parentContainer.getChildAt(i); RelativeLayout.LayoutParams para = (RelativeLayout.LayoutParams) view.getLayoutParams(); for (int j = 0; j < para.getRules().length; j++) { if (para.getRules()[j] == target.getId()) { para.getRules()[j] = _labelViewContainerID; } } view.setLayoutParams(para); } } parentContainer.removeView(target); // new dummy layout FrameLayout labelViewContainer = new FrameLayout(getContext()); ViewGroup.LayoutParams targetLayoutParam = target.getLayoutParams(); labelViewContainer.setLayoutParams(targetLayoutParam); target.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // add target and label in dummy layout labelViewContainer.addView(target); labelViewContainer.addView(this); labelViewContainer.setId(_labelViewContainerID); // add dummy layout in parent container parentContainer.addView(labelViewContainer, groupIndex, targetLayoutParam); } return true; }
From source file:com.github.jvanhie.discogsscrobbler.RecentlyPlayedFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //setup list view mList = new ListView(getActivity()); mList.setId(android.R.id.list);/*w w w. java 2 s . c o m*/ mList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { onListItemClick(view, i, l); } }); //create superframe for adding list and empty view FrameLayout superFrame = new FrameLayout(getActivity()); FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); superFrame.setLayoutParams(layoutparams); View emptyView = inflater.inflate(R.layout.fragment_empty, container, false); ((TextView) emptyView.findViewById(R.id.empty_heading)).setText("No recently played albums"); ((TextView) emptyView.findViewById(R.id.empty_text)).setText( "Your recently played list is empty. Once you start registering your played records they'll end up here"); /*initialize list with local discogs collection*/ if (mDiscogs == null) mDiscogs = Discogs.getInstance(getActivity()); loadList(); superFrame.addView(emptyView); mList.setEmptyView(emptyView); superFrame.addView(mList); return superFrame; }
From source file:com.google.android.apps.dashclock.configuration.ConfigureAppearanceFragment.java
private void configureStylePager(final ViewPager pager, final PagerPositionStrip positionStrip, final String[] styleNames, final String styleComponent, final int gravity, final String preference) { String currentStyleName = mCurrentStyleNames.get(preference); final LayoutInflater inflater = getActivity().getLayoutInflater(); pager.setAdapter(new PagerAdapter() { @Override//from ww w . j a va 2 s . c o m public int getCount() { return styleNames.length; } @Override public boolean isViewFromObject(View view, Object o) { return view == o; } @Override public Object instantiateItem(ViewGroup container, int position) { FrameLayout wrapper = new FrameLayout(getActivity()); ViewPager.LayoutParams wrapperLp = new ViewPager.LayoutParams(); wrapper.setLayoutParams(wrapperLp); String styleName = styleNames[position]; if (styleName.contains("analog")) { styleName += "_white"; } View v = inflater.inflate( AppearanceConfig.getLayoutByStyleName(getActivity(), styleComponent, styleName), container, false); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp.gravity = gravity; v.setLayoutParams(lp); wrapper.addView(v); container.addView(wrapper); return wrapper; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } }); pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mCurrentStyleNames.put(preference, styleNames[position]); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { positionStrip.setPosition(position + positionOffset); } }); positionStrip.setPageCount(styleNames.length); pager.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: showPositionStrips(true, -1); break; case MotionEvent.ACTION_UP: showPositionStrips(false, AUTO_HIDE_DELAY_MILLIS); break; } return false; } }); for (int i = 0; i < styleNames.length; i++) { if (currentStyleName.equals(styleNames[i])) { pager.setCurrentItem(i); positionStrip.setPosition(i); break; } } }
From source file:com.ashlikun.badgeview.BadgeView.java
public void setTargetView(View target) { if (getParent() != null) { ((ViewGroup) getParent()).removeView(this); }/* w ww. j av a2 s . co m*/ if (target == null) { return; } if (target.getParent() instanceof FrameLayout) { ((FrameLayout) target.getParent()).addView(this); } else if (target.getParent() instanceof ViewGroup) { // use a new Framelayout container for adding badge ViewGroup parentContainer = (ViewGroup) target.getParent(); int groupIndex = parentContainer.indexOfChild(target); parentContainer.removeView(target); FrameLayout badgeContainer = new FrameLayout(getContext()); ViewGroup.LayoutParams parentLayoutParams = target.getLayoutParams(); badgeContainer.setLayoutParams(parentLayoutParams); target.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); parentContainer.addView(badgeContainer, groupIndex, parentLayoutParams); badgeContainer.addView(target); badgeContainer.addView(this); } else if (target.getParent() == null) { Log.e(getClass().getSimpleName(), "ParentView is needed"); } }
From source file:org.wdd.app.android.catgirl.views.ActionSheet.java
private View createView() { FrameLayout parent = new FrameLayout(getContext()); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg = new View(getContext()); mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg.setBackgroundColor(Color.parseColor("#4e000000")); mBg.setId(ActionSheet.BG_VIEW_ID);/*from w w w. ja v a 2s. c o m*/ mBg.setOnClickListener(this); mPanel = new LinearLayout(getContext()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; mPanel.setLayoutParams(params); mPanel.setOrientation(LinearLayout.VERTICAL); parent.setPadding(0, 0, 0, getNavBarHeight(getActivity())); parent.addView(mBg); parent.addView(mPanel); return parent; }
From source file:com.tomeokin.lspush.biz.home.UriDialogFragment.java
@SuppressLint("InflateParams") @NonNull/* www . j a v a2 s. co m*/ @Override protected BaseDialogFragment.Builder config(@NonNull BaseDialogFragment.Builder builder) { View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_add_link, null); builder.addCustomMessageView(view); final View content = getActivity().getWindow().findViewById(Window.ID_ANDROID_CONTENT); final FrameLayout container = builder.getCustomViewHolder(); ViewGroup.LayoutParams lp = container.getLayoutParams(); lp.width = content.getWidth() / 6 * 5; container.setLayoutParams(lp); mUrlField = (EditText) view.findViewById(R.id.url_field); mNextButton = (TextView) view.findViewById(R.id.next_button); mNextButton.setTextColor(Color.BLACK); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getUrlInfo(); } }); mNextButton.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT && isAvailableCheck() && isValidWebUri(mUrlField.getText())) { getUrlInfo(); return true; } return false; } }); Drawable clear = getContext().getDrawable(R.drawable.search_clear); DrawableCompat.setTint(clear, ContextCompat.getColor(getContext(), R.color.blue_5_whiteout)); mNextButton.setCompoundDrawables(null, null, clear, null); mProgressBar = (ProgressBar) view.findViewById(R.id.next_progress); final String text = ClipboardUtils.getText(getContext()); if (!TextUtils.isEmpty(text) && isValidWebUri(text)) { mUrlField.setText(text); activeNextButton(); } else { disableNextButton(); } return builder; }
From source file:com.flexible.flexibleadapter.helpers.StickyHeaderHelper.java
private FrameLayout createContainer(int width, int height) { FrameLayout frameLayout = new FrameLayout(mRecyclerView.getContext()); frameLayout.setLayoutParams(new ViewGroup.LayoutParams(width, height)); return frameLayout; }
From source file:com.example.angelina.travelapp.map.MapActivity.java
/** * Restore map to original size and remove * views associated with displaying route segments. * @return MapFragment - The fragment containing the map *///from w ww . j ava2 s . c om public final MapFragment restoreMapAndRemoveRouteDetail() { // Remove the route directions final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0)); layout.requestLayout(); // Show the map final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); final FragmentManager fm = getSupportFragmentManager(); final MapFragment mapFragment = (MapFragment) fm.findFragmentById(R.id.map_fragment_container); mapFragment.removeRouteDetail(); return mapFragment; }
From source file:com.mobicage.rogerthat.ServiceBoundActivity.java
protected View wrapViewWithFab(View view) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH || !showFABMenu()) return view; FrameLayout frameLayout = new FrameLayout(this); frameLayout.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); frameLayout.addView(view);/*from www . ja v a 2s . c om*/ mFAB = new FloatingActionButton(this); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); layoutParams.gravity = getFabGravity(); int m = UIUtils.convertDipToPixels(this, 16); layoutParams.setMargins(m, m, m, m); mFAB.setLayoutParams(layoutParams); mFAB.setImageResource(R.drawable.ic_menu); mFAB.setColorNormalResId(R.color.mc_homescreen_background); mFAB.setColorPressedResId(R.color.mc_homescreen_background); mFAB.setColorRipple(R.color.mc_homescreen_background); mFAB.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { openOptionsMenu(); } }); mFAB.setVisibility(View.VISIBLE); frameLayout.addView(mFAB); return frameLayout; }