List of usage examples for android.widget FrameLayout FrameLayout
public FrameLayout(@NonNull Context context)
From source file:me.wizos.loread.view.webview.VideoImpl.java
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity;/*w ww . j av a 2 s . c o m*/ if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return; } // ? mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (videoView != null) { callback.onCustomViewHidden(); return; } // KLog.e("" + mWebView + " " + videoParentView); if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (videoParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); videoParentView = new FrameLayout(mActivity); videoParentView.setBackgroundColor(Color.BLACK); videoParentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); // ? mDecorView.addView(videoParentView); } // KLog.e("" + mWebView.getVisibility() + " " + videoParentView); this.mCallback = callback; this.videoView = view; videoParentView.addView(videoView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); videoParentView.setVisibility(View.VISIBLE); isPlaying = true; }
From source file:org.telegram.ui.IdenticonActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/*from www.ja v a 2 s . c o m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new LinearLayout(context); LinearLayout linearLayout = (LinearLayout) fragmentView; linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setWeightSum(100); linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); ImageView identiconView = new ImageView(context); identiconView.setScaleType(ImageView.ScaleType.FIT_XY); frameLayout.addView(identiconView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background)); frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); TextView textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLinksClickable(true); textView.setClickable(true); textView.setMovementMethod(new LinkMovementMethodMy()); //textView.setAutoLinkMask(Linkify.WEB_URLS); textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); textView.setGravity(Gravity.CENTER); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id); if (encryptedChat != null) { IdenticonDrawable drawable = new IdenticonDrawable(); identiconView.setImageDrawable(drawable); drawable.setEncryptedChat(encryptedChat); TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id); SpannableStringBuilder hash = new SpannableStringBuilder(); if (encryptedChat.key_hash.length > 16) { String hex = Utilities.bytesToHex(encryptedChat.key_hash); for (int a = 0; a < 32; a++) { if (a != 0) { if (a % 8 == 0) { hash.append('\n'); } else if (a % 4 == 0) { hash.append(' '); } } hash.append(hex.substring(a * 2, a * 2 + 2)); hash.append(' '); } hash.append("\n\n"); } hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name))); final String url = "telegram.org"; int index = hash.toString().indexOf(url); if (index != -1) { hash.setSpan( new URLSpanReplacement( LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } textView.setText(hash); } return fragmentView; }
From source file:com.fibrobook.viewpager.custom.CardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/*from www . ja v a2s .com*/ final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); LinearLayout l = new LinearLayout(getActivity()); params.setMargins(margin, margin, margin, margin); l.setLayoutParams(params); l.setGravity(Gravity.CENTER); l.setBackgroundResource(R.drawable.background_card); switch (position) { case 0: symphtomsView(l); break; case 1: dayView(l); break; } fl.addView(l); return fl; }
From source file:com.aboveware.abovegame.expandable.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 w w . ja v a 2 s . c o m*/ * <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 * AbsListFragment. 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) { FrameLayout root = new FrameLayout(getActivity()); FrameLayout lframe = new FrameLayout(getActivity()); 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)); ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); root.setLayoutParams(lp); return root; }
From source file:org.shaastra.helper.SuperAwesomeCardFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/* www . j a va 2 s. c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); //v.setBackgroundResource(R.drawable.background_card); v.setText("CARD " + (position + 1)); if (position == 0) { View v1 = inflater.inflate(R.layout.event_info, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.infotext); t1.setText(eintroduction); return v1; } else if (position == 1) { String Venue = new String(); Venue = evenue; final String SAC = elatlong; //String start=String.valueOf(l.getLatitude())+String.valueOf(l.getLongitude()); /* View v1=inflater.inflate(R.layout.map, container,false); v1.setLayoutParams(params); WebView wv=(WebView)v1.findViewById(R.id.wv1); wv.setWebChromeClient(new WebChromeClient()); //wv.loadUrl("https://maps.google.com/maps?saddr=13,80&daddr=13,80.02"); //wv.loadUrl("http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false"); wv.loadUrl("http://maps.google.com/maps?f=d&daddr=51.448,-0.972"); wv.getSettings().getBuiltInZoomControls(); */ View v1 = inflater.inflate(R.layout.map, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView location = (TextView) v1.findViewById(R.id.locationText); Button mapButton = (Button) v1.findViewById(R.id.mapButton); if (evenue.equalsIgnoreCase("NONE")) { mapButton.setAlpha(0); } else { mapButton.setAlpha(1); } location.setText(Venue); mapButton.setOnTouchListener(new View.OnTouchListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { v.setAlpha((float) 0.4); v.animate().setInterpolator(new DecelerateInterpolator()).scaleX(0.9f).scaleY(0.9f); } if (event.getAction() == MotionEvent.ACTION_UP) { v.setAlpha((float) 0.75); v.animate().setInterpolator(new OvershootInterpolator()).scaleX(1f).scaleY(1f); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&daddr=" + SAC)); intent.setComponent(new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity")); startActivity(intent); } return false; } }); return v1; } else if (position == 2) { View v1 = inflater.inflate(R.layout.event_info, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.infotext); t1.setText(eformat); return v1; } else if (position == 3) { View v1 = inflater.inflate(R.layout.prize, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.prizeText); t1.setText(eprize); return v1; } else if (position == 4) { v.setBackgroundColor(Color.GREEN); } else if (position == 5) { v.setBackgroundColor(Color.MAGENTA); } else if (position == 6) { v.setBackgroundColor(Color.MAGENTA); } fl.addView(v); return fl; }
From source file:com.community.yuequ.bottombar.BottomBarBadge.java
private void wrapTabAndBadgeInSameContainer(final BottomBarTab tab) { ViewGroup tabContainer = (ViewGroup) tab.getParent(); tabContainer.removeView(tab);//from w w w .ja v a2s .co m final FrameLayout badgeContainer = new FrameLayout(getContext()); badgeContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); badgeContainer.addView(tab); badgeContainer.addView(this); tabContainer.addView(badgeContainer, tab.getIndexInTabContainer()); badgeContainer.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { badgeContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this); adjustPositionAndSize(tab); } }); }
From source file:cn.jasonlv.siri.activity.MainActivity.java
public void onNavigationDrawerItemSelected(int position) { if (position == 1) { Intent intent = new Intent(this, TodoActivity.class); startActivity(intent);/*from w w w . ja va 2 s . c o m*/ } if (position == 0) { FrameLayout fragmentContainer = new FrameLayout(this); fragmentContainer.setId(fragmentConatainerId); container.addView(fragmentContainer); getFragmentManager().beginTransaction() .replace(fragmentConatainerId, TodoEditorFragment.newInstance("a", "a")).commit(); fragmentConatainerId++; } if (position == 2) { Intent intent = new Intent(this, Setting.class); startActivity(intent); } if (position == 3) { Intent intent = new Intent(this, AboutActivity.class); startActivity(intent); } }
From source file:net.peterkuterna.android.apps.devoxxsched.ui.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a GridView 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 va 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 GridFragment. 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.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout gframe = new FrameLayout(context); gframe.setId(INTERNAL_GRID_CONTAINER_ID); TextView tv = new TextView(context); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); gframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GridView gv = new GridView(context); gv.setId(android.R.id.list); gv.setDrawSelectorOnTop(false); gframe.addView(gv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(gframe, 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.yamin.kk.fragment.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a GridView 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 . 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 GridFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @SuppressWarnings("deprecation") @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 gframe = new FrameLayout(context); gframe.setId(INTERNAL_GRID_CONTAINER_ID); TextView tv = new TextView(context); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); gframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GridView gv = new GridView(context); gv.setId(android.R.id.list); gv.setDrawSelectorOnTop(false); gframe.addView(gv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(gframe, 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:vit.collegecode.mediadb.fragments.HeaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Activity activity = getActivity(); assert activity != null; mFrameLayout = new FrameLayout(activity); mHeader = onCreateHeaderView(inflater, mFrameLayout); mHeaderHeader = mHeader.findViewById(android.R.id.title); mHeaderBackground = mHeader.findViewById(android.R.id.background); assert mHeader.getLayoutParams() != null; mHeaderHeight = mHeader.getLayoutParams().height; mFakeHeader = new Space(activity); mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight)); View content = onCreateContentView(inflater, mFrameLayout); if (content instanceof ListView) { isListViewEmpty = true;/*from w w w . j ava 2 s . c o m*/ final ListView listView = (ListView) content; listView.addHeaderView(mFakeHeader); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { if (mOnScrollListener != null) { mOnScrollListener.onScrollStateChanged(absListView, scrollState); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (isListViewEmpty) { scrollHeaderTo(0); } else { final View child = absListView.getChildAt(0); assert child != null; scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight); } } }); } else { // Merge fake header view and content view. final LinearLayout view = new LinearLayout(activity); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setOrientation(LinearLayout.VERTICAL); view.addView(mFakeHeader); view.addView(content); // Put merged content to ScrollView final NotifyingScrollView scrollView = new NotifyingScrollView(activity); scrollView.addView(view); scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { @Override public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { scrollHeaderTo(-t); } }); content = scrollView; } mFrameLayout.addView(content); mFrameLayout.addView(mHeader); // Content overlay view always shows at the top of content. if ((mContentOverlay = onCreateContentOverlayView(inflater, mFrameLayout)) != null) { mFrameLayout.addView(mContentOverlay, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } // Post initial scroll mFrameLayout.post(new Runnable() { @Override public void run() { scrollHeaderTo(0, true); } }); Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_bottom); mFrameLayout.startAnimation(anim); return mFrameLayout; }