Java Code Examples for android.widget.RelativeLayout#getViewTreeObserver()

The following examples show how to use android.widget.RelativeLayout#getViewTreeObserver() . 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: ProfileFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void setupDeviderView(View view, int parentLayout, int childVerticalLineLayout) {
    final RelativeLayout layout = (RelativeLayout) view.findViewById(parentLayout);
    final RelativeLayout childLayout = (RelativeLayout) view.findViewById(childVerticalLineLayout);
    ViewTreeObserver viewTreeObserver = layout.getViewTreeObserver();


    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            int height = layout.getMeasuredHeight();
            float marginPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, LEFT_MARGIN, getActivity().getResources().getDisplayMetrics());
            float liineWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, LINE_WIDTH, getActivity().getResources().getDisplayMetrics());
            RelativeLayout.LayoutParams layoutPrams = new RelativeLayout.LayoutParams((int) liineWidth, height);
            layoutPrams.setMargins((int) marginPx, 0, 0, 0);
            childLayout.setLayoutParams(layoutPrams);
        }
    });
}
 
Example 2
Source File: CompactCalendarTab.java    From CompactCalendarView with MIT License 5 votes vote down vote up
private void openCalendarOnCreate(View v) {
    final RelativeLayout layout = v.findViewById(R.id.main_content);
    ViewTreeObserver vto = layout.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (Build.VERSION.SDK_INT < 16) {
                layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
            compactCalendarView.showCalendarWithAnimation();
        }
    });
}
 
Example 3
Source File: MultiColumnPullToRefreshListView.java    From EverMemo with MIT License 5 votes vote down vote up
private void init(){
	setVerticalFadingEdgeEnabled(false);

	headerContainer = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ptr_header, null);
	header = (RelativeLayout) headerContainer.findViewById(R.id.ptr_id_header);
	text = (TextView) header.findViewById(R.id.ptr_id_text);
	lastUpdatedTextView = (TextView) header.findViewById(R.id.ptr_id_last_updated);
	image = (ImageView) header.findViewById(R.id.ptr_id_image);
	spinner = (ProgressBar) header.findViewById(R.id.ptr_id_spinner);

	pullToRefreshText = getContext().getString(R.string.ptr_pull_to_refresh);
	releaseToRefreshText = getContext().getString(R.string.ptr_release_to_refresh);
	refreshingText = getContext().getString(R.string.ptr_refreshing);
	lastUpdatedText = getContext().getString(R.string.ptr_last_updated);

	flipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	flipAnimation.setInterpolator(new LinearInterpolator());
	flipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
	flipAnimation.setFillAfter(true);

	reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	reverseFlipAnimation.setInterpolator(new LinearInterpolator());
	reverseFlipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
	reverseFlipAnimation.setFillAfter(true);

	addHeaderView(headerContainer);
	setState(State.PULL_TO_REFRESH);
	scrollbarEnabled = isVerticalScrollBarEnabled();

	ViewTreeObserver vto = header.getViewTreeObserver();
	vto.addOnGlobalLayoutListener(new PTROnGlobalLayoutListener());

	//super.setOnItemClickListener(new PTROnItemClickListener());
	//super.setOnItemLongClickListener(new PTROnItemLongClickListener());
}