Java Code Examples for android.widget.FrameLayout#getChildCount()
The following examples show how to use
android.widget.FrameLayout#getChildCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDialogFragment.java From android-styled-dialogs with Apache License 2.0 | 6 votes |
@Override public void onShow(DialogInterface dialog) { if (getView() != null) { ScrollView vMessageScrollView = (ScrollView) getView().findViewById(R.id.sdl_message_scrollview); ListView vListView = (ListView) getView().findViewById(R.id.sdl_list); FrameLayout vCustomViewNoScrollView = (FrameLayout) getView().findViewById(R.id.sdl_custom); boolean customViewNoScrollViewScrollable = false; if (vCustomViewNoScrollView.getChildCount() > 0) { View firstChild = vCustomViewNoScrollView.getChildAt(0); if (firstChild instanceof ViewGroup) { customViewNoScrollViewScrollable = isScrollable((ViewGroup) firstChild); } } boolean listViewScrollable = isScrollable(vListView); boolean messageScrollable = isScrollable(vMessageScrollView); boolean scrollable = listViewScrollable || messageScrollable || customViewNoScrollViewScrollable; modifyButtonsBasedOnScrollableContent(scrollable); } }
Example 2
Source File: PictureAdapter.java From v9porn with MIT License | 6 votes |
@Override public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { FrameLayout view = (FrameLayout) object; for (int i = 0; i < view.getChildCount(); i++) { View childView = view.getChildAt(i); if (childView instanceof PhotoView) { childView.setOnClickListener(null); childView.setOnLongClickListener(null); GlideApp.with(container).clear(childView); view.removeViewAt(i); Logger.t(TAG).d("clean photoView"); } } container.removeView(view); Logger.t(TAG).d("destroyItem"); }
Example 3
Source File: UIUtils.java From DoraemonKit with Apache License 2.0 | 6 votes |
/** * 获得app的contentView * * @param activity * @return */ public static View getDokitAppContentView(Activity activity) { FrameLayout decorView = (FrameLayout) activity.getWindow().getDecorView(); View mAppContentView = (View) decorView.getTag(R.id.dokit_app_contentview_id); if (mAppContentView != null) { return mAppContentView; } for (int index = 0; index < decorView.getChildCount(); index++) { View child = decorView.getChildAt(index); //LogHelper.i(TAG, "childId=====>" + getIdText(child)); //解决与布局边框工具冲突的问题 if ((child instanceof LinearLayout && TextUtils.isEmpty(getIdText(child).trim())) || child instanceof FrameLayout) { //如果是DokitBorderView 则返回他下面的第一个子child if (getIdText(child).trim().equals(STR_VIEW_BORDER_Id)) { mAppContentView = ((ViewBorderFrameLayout) child).getChildAt(0); } else { mAppContentView = child; } mAppContentView.setTag(R.id.dokit_app_contentview_id); break; } } return mAppContentView; }
Example 4
Source File: PictureAdapter.java From v9porn with MIT License | 6 votes |
@Override public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { FrameLayout view = (FrameLayout) object; for (int i = 0; i < view.getChildCount(); i++) { View childView = view.getChildAt(i); if (childView instanceof PhotoView) { childView.setOnClickListener(null); childView.setOnLongClickListener(null); GlideApp.with(container).clear(childView); view.removeViewAt(i); Logger.t(TAG).d("clean photoView"); } } container.removeView(view); Logger.t(TAG).d("destroyItem"); }
Example 5
Source File: RecyclerViewFragment.java From visual-goodies with Apache License 2.0 | 6 votes |
/** * Sets a view to be displayed when the list is empty with optional LayoutParams. * @param view Displayed when the list is empty. * @param params Information about how view's layout in the countainer. */ public void setEmptyView(View view, FrameLayout.LayoutParams params){ emptyView = view; isEmptyViewEmptyText = true; FrameLayout frameLayout = (FrameLayout) getView(); if (frameLayout == null) return; //In order to avoid having more than one emptyViews added to the layout if (frameLayout.getChildCount() > 2) frameLayout.removeViewAt(2); if (this.emptyText != null) frameLayout.findViewById(android.R.id.text1).setVisibility(View.GONE); if (params == null) { params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; } frameLayout.addView(view, 1, params); this.emptyViewAddedToLayout = true; actuallySetEmptyView(); }
Example 6
Source File: AppUtil.java From weixin with Apache License 2.0 | 5 votes |
/** * 截取scrollview的屏幕 * **/ public static Bitmap getBitmapByView(FrameLayout scrollView) { int h = 0; int w = 0; Bitmap bitmap = null; // 获取listView实际高度 for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); w += scrollView.getChildAt(i).getWidth(); // scrollView.getChildAt(i).setBackgroundResource(R.drawable.bg3); } Log.d(LOGTAG, "实际高度:" + h); Log.d(LOGTAG, " 高度:" + scrollView.getHeight()); // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); // 测试输出 // FileOutputStream out = null; // try { // out = new FileOutputStream("/sdcard/screen_test.png"); // } catch (FileNotFoundException e) { // e.printStackTrace(); // } // try { // if (null != out) { // bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); // out.flush(); // out.close(); // } // } catch (IOException e) { // // TODO: handle exception // } return bitmap; }
Example 7
Source File: SingleFragmentActivity.java From timelapse-sony with GNU General Public License v3.0 | 5 votes |
@Override protected void onStart() { super.onStart(); FrameLayout frameLayout = findViewById(R.id.fragment_container); if(frameLayout != null && frameLayout.getChildCount() > 0) { mSnackBarConnectionLost = Snackbar.make(frameLayout.getChildAt(0), getString(R.string.connection_with_camera_lost), Snackbar.LENGTH_INDEFINITE); } else { mNotConnectedMessage = false; } }
Example 8
Source File: HomeActivityDelegate.java From Taskbar with Apache License 2.0 | 5 votes |
@Override public boolean onDrag(View v, DragEvent event) { switch(event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: default: // do nothing break; case DragEvent.ACTION_DRAG_ENTERED: FrameLayout container = (FrameLayout) v; if(container.getChildCount() == 0 || startDragIndex == desktopIcons.indexOfChild(container)) { v.setBackgroundColor(U.getAccentColor(HomeActivityDelegate.this)); v.setAlpha(0.5f); } break; case DragEvent.ACTION_DRAG_ENDED: View view = (View) event.getLocalState(); view.setVisibility(View.VISIBLE); // fall through case DragEvent.ACTION_DRAG_EXITED: v.setBackground(null); v.setAlpha(1); break; case DragEvent.ACTION_DROP: FrameLayout container2 = (FrameLayout) v; if(container2.getChildCount() == 0) { // Dropped, reassign View to ViewGroup View view2 = (View) event.getLocalState(); ViewGroup owner = (ViewGroup) view2.getParent(); owner.removeView(view2); container2.addView(view2); endDragIndex = desktopIcons.indexOfChild(container2); reassignDroppedIcon(); } break; } return true; }
Example 9
Source File: GridVideoViewContainerAdapter.java From FuAgoraDemoDroid with MIT License | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { VideoUserStatusHolder myHolder = ((VideoUserStatusHolder) holder); final VideoStatusData user = mUsers.get(position); log.debug("onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView); FrameLayout holderView = (FrameLayout) myHolder.itemView; holderView.setOnTouchListener(new OnDoubleTapListener(mContext) { @Override public void onDoubleTap(View view, MotionEvent e) { if (mListener != null) { mListener.onItemDoubleClick(view, user); } } @Override public void onSingleTapUp() { } }); if (holderView.getChildCount() == 0) { SurfaceView target = user.mView; stripSurfaceView(target); holderView.addView(target, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } }
Example 10
Source File: VideoViewAdapter.java From FuAgoraDemoDroid with MIT License | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { VideoUserStatusHolder myHolder = ((VideoUserStatusHolder) holder); final VideoStatusData user = mUsers.get(position); Log.d("VideoViewAdapter", "onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView); log.debug("onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView); FrameLayout holderView = (FrameLayout) myHolder.itemView; if (holderView.getChildCount() == 0) { SurfaceView target = user.mView; stripSurfaceView(target); holderView.addView(target, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } holderView.setOnTouchListener(new OnDoubleTapListener(mContext) { @Override public void onDoubleTap(View view, MotionEvent e) { if (mListener != null) { mListener.onItemDoubleClick(view, user); } } @Override public void onSingleTapUp() { } }); }
Example 11
Source File: ChartProgressBar.java From ChartProgressBar-Android with Apache License 2.0 | 5 votes |
public void resetBarValues() { if (oldFrameLayout != null) removeClickedBar(); final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount(); for (int i = 0; i < barsCount; i++) { FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i); int rootChildCount = rootFrame.getChildCount(); for (int j = 0; j < rootChildCount; j++) { View childView = rootFrame.getChildAt(j); if (childView instanceof LinearLayout) { //bar LinearLayout barContainerLinear = ((LinearLayout) childView); int barContainerCount = barContainerLinear.getChildCount(); for (int k = 0; k < barContainerCount; k++) { View view = barContainerLinear.getChildAt(k); if (view instanceof Bar) { BarAnimation anim = new BarAnimation(((Bar) view), 0, (int) (mDataList.get(i).getBarValue() * 100)); anim.setDuration(250); ((Bar) view).startAnimation(anim); } } } } } isBarsEmpty = false; }
Example 12
Source File: ChartProgressBar.java From ChartProgressBar-Android with Apache License 2.0 | 5 votes |
public void removeBarValues() { if (oldFrameLayout != null) removeClickedBar(); final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount(); for (int i = 0; i < barsCount; i++) { FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i); int rootChildCount = rootFrame.getChildCount(); for (int j = 0; j < rootChildCount; j++) { View childView = rootFrame.getChildAt(j); if (childView instanceof LinearLayout) { //bar LinearLayout barContainerLinear = ((LinearLayout) childView); int barContainerCount = barContainerLinear.getChildCount(); for (int k = 0; k < barContainerCount; k++) { View view = barContainerLinear.getChildAt(k); if (view instanceof Bar) { BarAnimation anim = new BarAnimation(((Bar) view), (int) (mDataList.get(i).getBarValue() * 100), 0); anim.setDuration(250); ((Bar) view).startAnimation(anim); } } } } } isBarsEmpty = true; }
Example 13
Source File: Bulletin.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static Bulletin find(@NonNull FrameLayout containerLayout) { for (int i = 0, size = containerLayout.getChildCount(); i < size; i++) { final View view = containerLayout.getChildAt(i); if (view instanceof Layout) { return ((Layout) view).bulletin; } } return null; }
Example 14
Source File: WebViewActivity.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
private void showErrorPage() { FrameLayout webParentView = (FrameLayout) mWebView.getParent(); initErrorPage();//初始化自定义页面 while (webParentView.getChildCount() > 1) { webParentView.removeViewAt(0); } @SuppressWarnings("deprecation") FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT); webParentView.addView(mErrorView, 0, lp); mIsErrorPage = true; }
Example 15
Source File: ChartProgressBar.java From ChartProgressBar-Android with Apache License 2.0 | 4 votes |
public void disableBar(int index) { final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount(); for (int i = 0; i < barsCount; i++) { FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i); int rootChildCount = rootFrame.getChildCount(); for (int j = 0; j < rootChildCount; j++) { if ((int) rootFrame.getTag() != index) continue; rootFrame.setEnabled(false); rootFrame.setClickable(false); View childView = rootFrame.getChildAt(j); if (childView instanceof LinearLayout) { //bar LinearLayout barContainerLinear = ((LinearLayout) childView); int barContainerCount = barContainerLinear.getChildCount(); for (int k = 0; k < barContainerCount; k++) { View view = barContainerLinear.getChildAt(k); if (view instanceof Bar) { Bar bar = (Bar) view; LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable(); layerDrawable.mutate(); ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1); GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable(); if (progressLayer != null) { if (mProgressDisableColor > 0) progressLayer.setColor(ContextCompat.getColor(mContext, mProgressDisableColor)); else progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray)); } } else { TextView titleTxtView = (TextView) view; if (mProgressDisableColor > 0) titleTxtView.setTextColor(ContextCompat.getColor(mContext, mProgressDisableColor)); else titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray)); } } } } } }
Example 16
Source File: ChartProgressBar.java From ChartProgressBar-Android with Apache License 2.0 | 4 votes |
public void enableBar(int index) { final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount(); for (int i = 0; i < barsCount; i++) { FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i); int rootChildCount = rootFrame.getChildCount(); for (int j = 0; j < rootChildCount; j++) { if ((int) rootFrame.getTag() != index) continue; rootFrame.setEnabled(true); rootFrame.setClickable(true); View childView = rootFrame.getChildAt(j); if (childView instanceof LinearLayout) { //bar LinearLayout barContainerLinear = ((LinearLayout) childView); int barContainerCount = barContainerLinear.getChildCount(); for (int k = 0; k < barContainerCount; k++) { View view = barContainerLinear.getChildAt(k); if (view instanceof Bar) { Bar bar = (Bar) view; LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable(); layerDrawable.mutate(); ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1); GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable(); if (progressLayer != null) { if (mProgressColor > 0) progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor)); else progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray)); } } else { TextView titleTxtView = (TextView) view; if (mProgressDisableColor > 0) titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor)); else titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray)); } } } } } }
Example 17
Source File: ChartProgressBar.java From ChartProgressBar-Android with Apache License 2.0 | 4 votes |
public void selectBar(int index) { final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount(); for (int i = 0; i < barsCount; i++) { FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i); int rootChildCount = rootFrame.getChildCount(); for (int j = 0; j < rootChildCount; j++) { if ((int) rootFrame.getTag() != index) continue; if (oldFrameLayout != null) clickBarOff(oldFrameLayout); clickBarOn(rootFrame); oldFrameLayout = rootFrame; } } }
Example 18
Source File: ChartProgressBar.java From ChartProgressBar-Android with Apache License 2.0 | 4 votes |
public void deselectBar(int index) { final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount(); for (int i = 0; i < barsCount; i++) { FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i); int rootChildCount = rootFrame.getChildCount(); for (int j = 0; j < rootChildCount; j++) { if ((int) rootFrame.getTag() != index) continue; clickBarOff(rootFrame); } } }
Example 19
Source File: Window.java From FloatUtil with MIT License | 4 votes |
public Window(WindowWrapper windowWrapper) { super(windowWrapper.getContext()); mContext = windowWrapper.getContext(); mWindowWrapper = windowWrapper; this.id = mWindowWrapper.WindowId; this.originalParams = windowWrapper.onRequestLayoutParams(); this.flags = windowWrapper.onRequestWindowFlags(); this.touchInfo = new TouchInfo(); touchInfo.ratio = (float) originalParams.width / originalParams.height; this.data = new Bundle(); // create the window contents FrameLayout content = new FrameLayout(mContext); content.setId(android.R.id.content); addView(content); mLongPressRunnable = new Runnable() { @Override public void run() { if (mWindowWrapper.handleLongClick()){ touchInfo.isLongPress = true; mWindowWrapper.onLongPressed(); } } }; content.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // pass all touch events to the implementation boolean consumed = false; final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager(); dispatchLongPress(event); // handle move and bring to front consumed = windowManager.onTouchHandleMove(Window.this, v, event) || consumed; // alert implementation consumed = mWindowWrapper.onTouchBody(Window.this, v, event) || consumed; return consumed; } }); // attach the view corresponding to the id from the // implementation windowWrapper.onCreateAndAttachView(content); // make sure the implementation attached the view if (content.getChildCount() == 0) { Log.e(TAG, "You must attach your view to the given frame in onCreateAndAttachView()"); } // attach the existing tag from the frame to the window setTag(content.getTag()); windowWrapper.isCreated = true; }
Example 20
Source File: ChartProgressBar.java From ChartProgressBar-Android with Apache License 2.0 | 3 votes |
private void clickBarOff(FrameLayout frameLayout) { pins.get((int) frameLayout.getTag()).setVisibility(View.INVISIBLE); isOldBarClicked = false; int childCount = frameLayout.getChildCount(); for (int i = 0; i < childCount; i++) { View childView = frameLayout.getChildAt(i); if (childView instanceof LinearLayout) { LinearLayout linearLayout = (LinearLayout) childView; Bar bar = (Bar) linearLayout.getChildAt(0); TextView titleTxtView = (TextView) linearLayout.getChildAt(1); LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable(); layerDrawable.mutate(); ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1); GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable(); if (progressLayer != null) { progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor)); } titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor)); } } }