List of usage examples for android.widget FrameLayout addView
public void addView(View child, int index)
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mapView = super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.fragment_map, container, false); FrameLayout layout = (FrameLayout) v.findViewById(R.id.map_container); layout.addView(mapView, 0); mFloorControls = layout.findViewById(R.id.map_floorcontrol); // setup floor button handlers mFloorButtons[0] = (Button) v.findViewById(R.id.map_floor1); mFloorButtons[1] = (Button) v.findViewById(R.id.map_floor2); mFloorButtons[2] = (Button) v.findViewById(R.id.map_floor3); mFloorButtons[0].setVisibility(View.GONE); mFloorButtons[1].setVisibility(View.GONE); mFloorButtons[2].setVisibility(View.GONE); mFloorControls.setVisibility(View.GONE); for (int i = 0; i < mFloorButtons.length; i++) { final int j = i; mFloorButtons[i].setOnClickListener(new View.OnClickListener() { @Override/*from w w w.ja va 2 s . c o m*/ public void onClick(View v) { showFloor(j); } }); } // get the height and width of the view mapView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override public void onGlobalLayout() { final View v = getView(); mHeight = v.getHeight(); mWidth = v.getWidth(); // also requires width and height enableFloors(); if (v.getViewTreeObserver().isAlive()) { // remove this layout listener if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { v.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { v.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } } }); if (mMap == null) { setupMap(true); } // load all markers LoaderManager lm = getActivity().getSupportLoaderManager(); lm.initLoader(MarkerQuery._TOKEN, null, this); // load the tile overlays lm.initLoader(OverlayQuery._TOKEN, null, this); // load tracks data lm.initLoader(TracksQuery._TOKEN, null, this); return v; }
From source file:org.getlantern.firetweet.fragment.support.BaseSupportListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a ListView whose id is * {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to * be shown when the list is empty./* ww w . j a v a2 s .c om*/ * <p/> * <p/> * If you are overriding this method with your own custom content, consider * including the standard layout {@link android.R.layout#list_content} in * your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final ExtendedFrameLayout lframe = new ExtendedFrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); lframe.setTouchInterceptor(mInternalOnTouchListener); final TextView tv = new TextView(getActivity()); tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context)); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lv.setOnScrollListener(this); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:com.readboy.mathproblem.app.ExpandableListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. *//*from w ww .j a v a 2 s . c o m*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ /*ExpandableListView expandableListView = (ExpandableListView) View.inflate( getActivity(), R.layout.expandable_gradelist, lframe);*/ // ------------------------------------------------------------------ ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ /* ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));*/ // ------------------------------------------------------------------ root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:com.sabaibrowser.UI.java
public void showCustomView(View view, int requestedOrientation, WebChromeClient.CustomViewCallback callback) { // if a view already exists then immediately terminate the new one if (mCustomView != null) { callback.onCustomViewHidden();//from w ww .ja v a2 s . c om return; } mOriginalOrientation = mActivity.getRequestedOrientation(); FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); mFullscreenContainer = new FullscreenHolder(mActivity); mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS); decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS); mCustomView = view; setImmersiveFullscreen(true); ((BrowserWebView) getWebView()).setVisibility(View.INVISIBLE); mCustomViewCallback = callback; mActivity.setRequestedOrientation(requestedOrientation); }
From source file:com.google.android.apps.gutenberg.ScannerActivity.java
private void showCheckinAnimation(Checkin checkin) { if (mLastAnimator != null) { mLastAnimator.cancel();/*from w w w. jav a2 s . c o m*/ } final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover); cover.setVisibility(View.VISIBLE); final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer); final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; holder.setWillAnimate(true); holder.bind(checkin, mImageLoader); holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0)); float elevation = getResources().getDimension(R.dimen.popup_elevation); ViewCompat.setTranslationZ(holder.itemView, elevation); holder.setLines(false, false); layer.addView(holder.itemView, lp); // Interpolator for animators FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator(); // Pop-up Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up); popUpAnim.setTarget(holder.itemView); popUpAnim.setInterpolator(interpolator); popUpAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.animateCheckin(); } }); // Wait ObjectAnimator waitAnim = new ObjectAnimator(); waitAnim.setTarget(holder.itemView); waitAnim.setPropertyName("translationY"); waitAnim.setFloatValues(0.f, 0.f); waitAnim.setDuration(2000); // Slide-down ObjectAnimator slideDownAnim = new ObjectAnimator(); slideDownAnim.setTarget(holder.itemView); slideDownAnim.setPropertyName("translationY"); slideDownAnim.setFloatValues(0.f, calcSlideDistance()); slideDownAnim.setInterpolator(interpolator); // Landing anim ObjectAnimator landingAnim = new ObjectAnimator(); landingAnim.setTarget(holder.itemView); landingAnim.setPropertyName("translationZ"); landingAnim.setFloatValues(elevation, 0.f); landingAnim.setInterpolator(interpolator); landingAnim.setDuration(500); // Play the animators AnimatorSet set = new AnimatorSet(); set.setInterpolator(interpolator); set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { clean(); } @Override public void onAnimationCancel(Animator animation) { clean(); } private void clean() { mLastAnimator = null; layer.removeAllViews(); cover.setVisibility(View.INVISIBLE); } }); mLastAnimator = set; set.start(); }
From source file:org.telegram.ui.StickersActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); if (currentType == StickersQuery.TYPE_IMAGE) { actionBar.setTitle(LocaleController.getString("Stickers", R.string.Stickers)); } else {/*ww w. j av a 2 s.c o m*/ actionBar.setTitle(LocaleController.getString("Masks", R.string.Masks)); } actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); listView = new RecyclerListView(context); listView.setFocusable(true); listView.setTag(7); LinearLayoutManager layoutManager = new LinearLayoutManager(context); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); listView.setLayoutManager(layoutManager); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new TouchHelperCallback()); itemTouchHelper.attachToRecyclerView(listView); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (position >= stickersStartRow && position < stickersEndRow && getParentActivity() != null) { sendReorder(); final TLRPC.TL_messages_stickerSet stickerSet = StickersQuery.getStickerSets(currentType) .get(position - stickersStartRow); ArrayList<TLRPC.Document> stickers = stickerSet.documents; if (stickers == null || stickers.isEmpty()) { return; } showDialog( new StickersAlert(getParentActivity(), StickersActivity.this, null, stickerSet, null)); } else if (position == featuredRow) { presentFragment(new FeaturedStickersActivity()); } else if (position == archivedRow) { presentFragment(new ArchivedStickersActivity(currentType)); } else if (position == masksRow) { presentFragment(new StickersActivity(StickersQuery.TYPE_MASK)); } } }); return fragmentView; }
From source file:com.dev.foundingfourfathers.alchemy.BrowseCocktails.DetailFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { FrameLayout root = (FrameLayout) view; Context context = view.getContext(); assert context != null; // This is how the fragment looks at first. Since the transition is one-way, we don't need to make // this a Scene. View item = LayoutInflater.from(context).inflate(R.layout.item_mixed_drink_grid, root, false); assert item != null; bind(item);// w ww .j a v a2 s.com // We adjust the position of the initial image with LayoutParams using the values supplied // as the fragment arguments. Bundle args = getArguments(); FrameLayout.LayoutParams params = null; if (args != null) { params = new FrameLayout.LayoutParams(args.getInt(ARG_WIDTH), args.getInt(ARG_HEIGHT)); params.topMargin = args.getInt(ARG_Y); params.leftMargin = args.getInt(ARG_X); } root.addView(item, params); }
From source file:id.nci.stm_9.ExpandableListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses can override to * replace with their own layout. If doing so, the returned view hierarchy <em>must</em> have a * ListView whose id is {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when the * list is empty./*from w ww. j a va 2 s . co m*/ * * <p> * If you are overriding this method with your own custom content, consider including the * standard layout {@link android.R.layout#list_content} in your layout file, so that you * continue to retain all of the standard behavior of ListFragment. In particular, this is * currently the only way to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.java
private void populateTabStrip() { final TabAdapter adapter = (TabAdapter) viewPager.getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { ImageView tabIconView = null; final View tabView = (tabProvider == null) ? createDefaultTabView(adapter.getDrawableId(i)) : tabProvider.createTabView(tabStrip, i, adapter); if (tabView == null) { throw new IllegalStateException("tabView is null."); }//from ww w . j a v a2s .c om if (distributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } if (ImageView.class.isInstance(tabView)) { tabIconView = (ImageView) tabView; } if (tabIconView != null) { tabIconView.setImageResource(adapter.getDrawableId(i)); if (viewPager.getCurrentItem() == i) { tabIconView.setSelected(true); } } if (internalTabClickListener != null) { tabView.setOnClickListener(internalTabClickListener); } if (i == 1) { View view = LayoutInflater.from(getContext()).inflate(R.layout.counter, tabStrip, false); FrameLayout counterLayout = (FrameLayout) view.findViewById(R.id.counter_layout); messageBackground = (ImageView) view.findViewById(R.id.message_background); counter = (TextView) view.findViewById(R.id.counter); counter.setText(String.valueOf(messageCount)); ImageView imageView = new ImageView(getContext()); imageView.setImageResource(adapter.getDrawableId(i)); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); counterLayout.addView(imageView, 0); if (internalTabClickListener != null) { view.setOnClickListener(internalTabClickListener); } if (messageCount > 0) { messageBackground.setVisibility(VISIBLE); counter.setVisibility(VISIBLE); } else { messageBackground.setVisibility(GONE); counter.setVisibility(GONE); } tabStrip.addView(view); } else { tabStrip.addView(tabView); } if (i == viewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:org.dvbviewer.controller.ui.base.BaseListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * /* w ww . j ava 2 s.c om*/ * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. * * @param inflater the inflater * @param container the container * @param savedInstanceState the saved instance state * @return the view * @author RayBa * @date 07.04.2013 */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); if (layoutRessource > 0) { View v = getLayoutInflater(savedInstanceState).inflate(layoutRessource, null); return v; } else { FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyle); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; } }