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

The following examples show how to use android.widget.RelativeLayout#setFocusableInTouchMode() . 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: FloatingToolbar.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private ViewGroup createContentContainer(Context context) {
    RelativeLayout contentContainer = new RelativeLayout(context);
    ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.bottomMargin = layoutParams.leftMargin = layoutParams.topMargin = layoutParams.rightMargin = AndroidUtilities.dp(20);
    contentContainer.setLayoutParams(layoutParams);
    contentContainer.setElevation(AndroidUtilities.dp(2));
    contentContainer.setFocusable(true);
    contentContainer.setFocusableInTouchMode(true);
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    int r = AndroidUtilities.dp(6);
    shape.setCornerRadii(new float[] { r, r, r, r, r, r, r, r });
    if (currentStyle == STYLE_DIALOG) {
        shape.setColor(Theme.getColor(Theme.key_dialogBackground));
    } else if (currentStyle == STYLE_BLACK) {
        shape.setColor(0xf9222222);
    } else if (currentStyle == STYLE_THEME) {
        shape.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    }
    contentContainer.setBackgroundDrawable(shape);
    contentContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    contentContainer.setClipToOutline(true);
    return contentContainer;
}
 
Example 2
Source File: FloatingToolbar.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private ViewGroup createContentContainer(Context context) {
    RelativeLayout contentContainer = new RelativeLayout(context);
    ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.bottomMargin = layoutParams.leftMargin = layoutParams.topMargin = layoutParams.rightMargin = AndroidUtilities.dp(20);
    contentContainer.setLayoutParams(layoutParams);
    contentContainer.setElevation(AndroidUtilities.dp(2));
    contentContainer.setFocusable(true);
    contentContainer.setFocusableInTouchMode(true);
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    int r = AndroidUtilities.dp(6);
    shape.setCornerRadii(new float[] { r, r, r, r, r, r, r, r });
    if (currentStyle == STYLE_DIALOG) {
        shape.setColor(Theme.getColor(Theme.key_dialogBackground));
    } else if (currentStyle == STYLE_BLACK) {
        shape.setColor(0xf9222222);
    } else if (currentStyle == STYLE_THEME) {
        shape.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    }
    contentContainer.setBackgroundDrawable(shape);
    contentContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    contentContainer.setClipToOutline(true);
    return contentContainer;
}
 
Example 3
Source File: AccessibilityGuideFloatView.java    From FileManager with Apache License 2.0 5 votes vote down vote up
private void initWindowView() {
    mContentView = (RelativeLayout) LayoutInflater.from(mContext).inflate(R.layout.accessibility_guide_float_window_layout, null);
    mContentView.setFocusableInTouchMode(true);
    mFloatViewLayout = (AccessibilityGuideFloatViewLayout) mContentView.findViewById(R.id.guide_float_window_layout);
    mFloatViewLayout.getCloseView().setOnClickListener(this);
    mContentView.setOnKeyListener((v, keyCode, event) -> {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            dimiss();
        }
        return false;
    });
}
 
Example 4
Source File: XulDemoBaseActivity.java    From starcor.xul with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void initLayout() {
	mLayout = new RelativeLayout(this) {
		Rect drawingRc = new Rect();

		@Override
		protected void dispatchDraw(Canvas canvas) {
			getDrawingRect(drawingRc);
			if ((mXulPageRender != null) && mXulPageRender.beginDraw(canvas, drawingRc)) {
				super.dispatchDraw(canvas);
				mXulPageRender.endDraw();
			} else {
				super.dispatchDraw(canvas);
			}

			synchronized (mRedrawWaitableObject) {
				mRedrawWaitableObject.notifyAll();
			}
		}

		@Override
		protected void onFocusChanged(boolean gainFocus, int direction,
		                              Rect previouslyFocusedRect) {
			super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
			if (!gainFocus) {
				LogUtil.d(TAG, "focus lost!!!!");
				post(new Runnable() {
					@Override
					public void run() {
						LogUtil.d(TAG, "update focus!!!!");
						View view = findFocus();
						IXulExternalView xulView = null;
						if (view != null) {
							if (view instanceof IXulExternalView) {
								xulView = (IXulExternalView) view;
							} else {
								ViewParent vp = view.getParent();
								while (vp != null && !(vp instanceof IXulExternalView)) {
									vp = vp.getParent();
								}
								if (vp != null) {
									xulView = (IXulExternalView) vp;
								}
							}
						}
						if (xulView != null) {
							XulView customItemByExtView =
								mXulPageRender.findCustomItemByExtView(xulView);
							mXulPageRender.getLayout().requestFocus(customItemByExtView);
						}
					}
				});
			}
		}
	};
	mLayout.setFocusable(true);
	mLayout.setFocusableInTouchMode(true);
	mLayout.setLayoutParams(new RelativeLayout.LayoutParams(
		ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}