Search in sources :

Example 46 with FrameLayout

use of android.widget.FrameLayout in project material-components-android by material-components.

the class BottomSheetDialog method wrapInBottomSheet.

private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) {
    final CoordinatorLayout coordinator = (CoordinatorLayout) View.inflate(getContext(), R.layout.design_bottom_sheet_dialog, null);
    if (layoutResId != 0 && view == null) {
        view = getLayoutInflater().inflate(layoutResId, coordinator, false);
    }
    FrameLayout bottomSheet = (FrameLayout) coordinator.findViewById(R.id.design_bottom_sheet);
    mBehavior = BottomSheetBehavior.from(bottomSheet);
    mBehavior.setBottomSheetCallback(mBottomSheetCallback);
    mBehavior.setHideable(mCancelable);
    if (params == null) {
        bottomSheet.addView(view);
    } else {
        bottomSheet.addView(view, params);
    }
    // We treat the CoordinatorLayout as outside the dialog though it is technically inside
    coordinator.findViewById(R.id.touch_outside).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mCancelable && isShowing() && shouldWindowCloseOnTouchOutside()) {
                cancel();
            }
        }
    });
    // Handle accessibility events
    ViewCompat.setAccessibilityDelegate(bottomSheet, new AccessibilityDelegateCompat() {

        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
            super.onInitializeAccessibilityNodeInfo(host, info);
            if (mCancelable) {
                info.addAction(AccessibilityNodeInfoCompat.ACTION_DISMISS);
                info.setDismissable(true);
            } else {
                info.setDismissable(false);
            }
        }

        @Override
        public boolean performAccessibilityAction(View host, int action, Bundle args) {
            if (action == AccessibilityNodeInfoCompat.ACTION_DISMISS && mCancelable) {
                cancel();
                return true;
            }
            return super.performAccessibilityAction(host, action, args);
        }
    });
    bottomSheet.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent event) {
            // Consume the event and prevent it from falling through
            return true;
        }
    });
    return coordinator;
}
Also used : Bundle(android.os.Bundle) FrameLayout(android.widget.FrameLayout) AccessibilityDelegateCompat(android.support.v4.view.AccessibilityDelegateCompat) AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 47 with FrameLayout

use of android.widget.FrameLayout in project robolectric by robolectric.

the class ShadowViewGroupTest method removeAllViews_shouldRequestLayout.

@Test
public void removeAllViews_shouldRequestLayout() throws Exception {
    View view = new View(context);
    ViewGroup viewGroup = new FrameLayout(context);
    viewGroup.addView(view);
    shadowOf(viewGroup).setDidRequestLayout(false);
    viewGroup.removeAllViews();
    assertThat(shadowOf(viewGroup).didRequestLayout()).isTrue();
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test)

Example 48 with FrameLayout

use of android.widget.FrameLayout in project robolectric by robolectric.

the class ShadowViewGroupTest method addView_whenChildAlreadyHasAParent_shouldThrow.

@Test
public void addView_whenChildAlreadyHasAParent_shouldThrow() throws Exception {
    ViewGroup newRoot = new FrameLayout(context);
    try {
        newRoot.addView(child1);
        fail("Expected IllegalStateException");
    } catch (IllegalStateException e) {
    // pass
    }
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) Test(org.junit.Test)

Example 49 with FrameLayout

use of android.widget.FrameLayout in project robolectric by robolectric.

the class ShadowViewGroupTest method shouldKnowWhenOnInterceptTouchEventWasCalled.

@Test
public void shouldKnowWhenOnInterceptTouchEventWasCalled() throws Exception {
    ViewGroup viewGroup = new FrameLayout(context);
    MotionEvent touchEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0);
    viewGroup.onInterceptTouchEvent(touchEvent);
    assertThat(shadowOf(viewGroup).getInterceptedTouchEvent()).isEqualTo(touchEvent);
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) MotionEvent(android.view.MotionEvent) Test(org.junit.Test)

Example 50 with FrameLayout

use of android.widget.FrameLayout in project PullToRefreshLibrary by harichen.

the class PullToRefreshAdapterViewBase method setEmptyView.

/**
	 * Sets the Empty View to be used by the Adapter View.
	 * <p/>
	 * We need it handle it ourselves so that we can Pull-to-Refresh when the
	 * Empty View is shown.
	 * <p/>
	 * Please note, you do <strong>not</strong> usually need to call this method
	 * yourself. Calling setEmptyView on the AdapterView will automatically call
	 * this method and set everything up. This includes when the Android
	 * Framework automatically sets the Empty View based on it's ID.
	 * 
	 * @param newEmptyView - Empty View to be used
	 */
public final void setEmptyView(View newEmptyView) {
    FrameLayout refreshableViewWrapper = getRefreshableViewWrapper();
    if (null != newEmptyView) {
        // New view needs to be clickable so that Android recognizes it as a
        // target for Touch Events
        newEmptyView.setClickable(true);
        ViewParent newEmptyViewParent = newEmptyView.getParent();
        if (null != newEmptyViewParent && newEmptyViewParent instanceof ViewGroup) {
            ((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
        }
        // We need to convert any LayoutParams so that it works in our
        // FrameLayout
        FrameLayout.LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams());
        if (null != lp) {
            refreshableViewWrapper.addView(newEmptyView, lp);
        } else {
            refreshableViewWrapper.addView(newEmptyView);
        }
    }
    if (mRefreshableView instanceof EmptyViewMethodAccessor) {
        ((EmptyViewMethodAccessor) mRefreshableView).setEmptyViewInternal(newEmptyView);
    } else {
        mRefreshableView.setEmptyView(newEmptyView);
    }
    mEmptyView = newEmptyView;
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) EmptyViewMethodAccessor(com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor)

Aggregations

FrameLayout (android.widget.FrameLayout)634 View (android.view.View)244 TextView (android.widget.TextView)143 ViewGroup (android.view.ViewGroup)128 ImageView (android.widget.ImageView)95 LinearLayout (android.widget.LinearLayout)89 ListView (android.widget.ListView)54 AdapterView (android.widget.AdapterView)49 Button (android.widget.Button)44 LayoutInflater (android.view.LayoutInflater)42 Bitmap (android.graphics.Bitmap)41 LayoutParams (android.view.ViewGroup.LayoutParams)37 AbsListView (android.widget.AbsListView)37 Context (android.content.Context)35 Intent (android.content.Intent)28 Activity (android.app.Activity)25 TextureView (android.view.TextureView)25 ColorDrawable (android.graphics.drawable.ColorDrawable)23 FileOutputStream (java.io.FileOutputStream)23 Drawable (android.graphics.drawable.Drawable)20