Java Code Examples for android.view.ViewGroup#setBackgroundColor()

The following examples show how to use android.view.ViewGroup#setBackgroundColor() . 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: ImmersiveModeUtils.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
/**
     * 仅对使用了Actionbar的起作用
     * xml中需使用父控件如LinearLayout框住,并设置为 android:fitsSystemWindows="true"
     *
     * 对getActibar设置了hide()的,设置为 android:fitsSystemWindows="false" 并需要手动paddingTop
     *
     * @param baseActivity
     * @param color         状态栏的颜色
     * @param paddingTop    是否padding上部分(高度为状态栏高度)
     * @param paddingBottom 是否padding下部分
     */
    public static void immersiveAboveAPI19(AppCompatActivity baseActivity, int color, boolean paddingTop, boolean paddingBottom) {
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {

            Window window = baseActivity.getWindow();
            window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//
            ViewGroup view = (ViewGroup) baseActivity.getWindow().getDecorView();
            view.setBackgroundColor(color);

            if (paddingTop) {
                view.setPadding(0, (paddingTop ? DeviceUtils.getStatusBarHeight(baseActivity) : 0), 0,
                        ((baseActivity.getSupportActionBar() != null && paddingBottom)
                                ? DeviceUtils.getActionBarHeight(baseActivity) : 0));

                ZogUtils.printError(ImmersiveModeUtils.class, "immersive no actionbar");

            }
        }
    }
 
Example 2
Source File: CompanionWatchFaceConfigActivity.java    From FORMWatchFace with Apache License 2.0 6 votes vote down vote up
private void updatePreviewView(Theme theme, ViewGroup clockContainerView, FormClockView clockView) {
    if (theme == Themes.MUZEI_THEME) {
        if (mMuzeiLoadedArtwork != null) {
            ((ImageView) clockContainerView.findViewById(R.id.background_image))
                    .setImageBitmap(mMuzeiLoadedArtwork.bitmap);
            clockView.setColors(
                    mMuzeiLoadedArtwork.color1,
                    mMuzeiLoadedArtwork.color2,
                    Color.WHITE);
        }
        clockContainerView.setBackgroundColor(Color.BLACK);
    } else {
        ((ImageView) clockContainerView.findViewById(R.id.background_image))
                .setImageDrawable(null);
        final Resources res = getResources();
        clockView.setColors(
                res.getColor(theme.lightRes),
                res.getColor(theme.midRes),
                Color.WHITE);
        clockContainerView.setBackgroundColor(
                res.getColor(theme.darkRes));
    }
}
 
Example 3
Source File: SlidePanelDemo.java    From support with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.slidepanel_layout);
        mContentView = (ViewGroup) findViewById(R.id.fl_container);
//        ListView menuList = (ListView) findViewById(R.id.lv_memu_list);
//        menuList.setAdapter(new ArrayAdapter<String>(
//                this,
//                android.R.layout.simple_list_item_1,
//                android.R.id.text1,
//                new String[]{"RED", "BLUE", "CYAN", "GREEN", "YELLOW"}
//        ));
//        menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                mContentView.setBackgroundColor(mColors[position]);
//            }
//        });
        mContentView.setBackgroundColor(0xff03a9f4);

    }
 
Example 4
Source File: ParanoidVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override public void onCreate() {
    super.onCreate();
    oneVolume = false;
    Context context = getContext();
    LayoutInflater inflater = LayoutInflater.from(context);

    // Load default PA color if the user doesn't have a preference.
    if (!has(COLOR)) color = context.getResources().getColor(R.color.pa_volume_scrubber);
    if (!has(BACKGROUND)) backgroundColor = context.getResources().getColor(R.color.volume_panel_bg);
    root = (ViewGroup) inflater.inflate(R.layout.pa_volume_adjust, null);

    mPanel = (ViewGroup) root.findViewById(R.id.visible_panel);

    mSliderGroup = (ViewGroup) root.findViewById(R.id.slider_group);
    mMoreButton = root.findViewById(R.id.expand_button);
    mPanel.setBackgroundColor(backgroundColor);

    loadSystemSettings();
    mMoreButton.setOnClickListener(expandListener);

    if (null == mStreamControls)
        mStreamControls = new SparseArray<StreamControl>(StreamResources.STREAMS.length);

    mLayout = root;
}
 
Example 5
Source File: StatusBarUtil.java    From MaoWanAndoidClient with Apache License 2.0 5 votes vote down vote up
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
                                        @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {
                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
 
Example 6
Source File: HorzItemList.java    From Primary with GNU General Public License v3.0 5 votes vote down vote up
private ViewGroup addItem(int pos, String key) {
    if (mListItems.containsKey(key)) {
        return mListItems.get(key);
    }
    ViewGroup item = (ViewGroup) LayoutInflater.from(mParent).inflate(mItemLayoutId, null);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.setMargins(10, 10, 10, 10);
    item.setLayoutParams(lp);

    item.setBackgroundColor(normalColor);

    if (pos == -1) pos = mListItems.size();
    populateItem(key, item, pos);


    item.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setSelected(view);
            onItemClicked(mListItemsRev.get(view), (LinearLayout) view);
        }
    });
    item.setTag(key);
    mItemsListView.addView(item);
    mListItems.put(key, item);
    mListItemsRev.put(item, key);

    return item;
}
 
Example 7
Source File: UIStatusBarController.java    From FastAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
                                        @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {
                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
 
Example 8
Source File: StatusBarUtil.java    From stynico with MIT License 5 votes vote down vote up
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {
@Override
public void run() {
    coordinatorLayout.requestLayout();
}
   });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
 
Example 9
Source File: CustomizeViews.java    From placeholderj with Apache License 2.0 5 votes vote down vote up
private void customizeViewError(ViewGroup viewError, ImageView viewErrorImage,
                                TextView viewErrorMessage, Button viewErrorTryAgainButton) {
    if (viewError != null) {
        if (mPlaceHolderManager.mViewErrorBackgroundColor != 0) {
            viewError.setBackgroundColor(getColor(mPlaceHolderManager.mViewErrorBackgroundColor));
        } else if (mPlaceHolderManager.mViewErrorBackgroundResource > 0) {
            viewError.setBackgroundResource(mPlaceHolderManager.mViewErrorBackgroundResource);
        }
        if (mPlaceHolderManager.mViewErrorText > 0) {
            viewErrorMessage.setText(mPlaceHolderManager.mViewErrorText);
        }
        if (mPlaceHolderManager.mViewErrorTextSize > 0) {
            setTextSize(viewErrorMessage, mPlaceHolderManager.mViewErrorTextSize);
        }
        if (mPlaceHolderManager.mViewErrorTextColor != 0) {
            viewErrorMessage.setTextColor(getColor(mPlaceHolderManager.mViewErrorTextColor));
        }
        if (mPlaceHolderManager.mViewErrorTryAgainButtonText > 0) {
            viewErrorTryAgainButton.setText(mPlaceHolderManager.mViewErrorTryAgainButtonText);
        }
        if (mPlaceHolderManager.mViewErrorTryAgainButtonTextColor > 0) {
            viewErrorTryAgainButton.setTextColor(mPlaceHolderManager.mViewErrorTryAgainButtonTextColor);
        }
        if (mPlaceHolderManager.mViewErrorTryAgainButtonBackgroundResource > 0) {
            int backgroundRes = mPlaceHolderManager.mViewErrorTryAgainButtonBackgroundResource;
            viewErrorTryAgainButton.setBackgroundResource(backgroundRes);
        }
        if (mPlaceHolderManager.mViewErrorImage > 0) {
            viewErrorImage.setImageDrawable(getDrawable(mPlaceHolderManager.mViewErrorImage));
        }
    }
}
 
Example 10
Source File: TransitionUtils.java    From KotlinMVPRxJava2Dagger2GreenDaoRetrofitDemo with Apache License 2.0 5 votes vote down vote up
/**
 *创建Reveal动画并执行
 *
 * @param viewRoot 要执行动画的布局
 * @param color 揭露的颜色
 * @param cx 揭露点的X坐标
 * @param cy 揭露点的Y坐标
 * @return 返回创建成功的动画
 */
@TargetApi(21)
private Animator animateRevealColorFromCoordinates(ViewGroup viewRoot, int color, int cx, int cy, Activity activity) {
    float finalRadius= (float) Math.hypot(viewRoot.getWidth(),viewRoot.getHeight());

    Animator anim= ViewAnimationUtils.createCircularReveal(viewRoot,cx,cy,0,finalRadius);
    viewRoot.setBackgroundColor(ContextCompat.getColor(activity,color));
    anim.setDuration(1000);
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.start();
    return anim;
}
 
Example 11
Source File: StatusBarUtil.java    From styT with Apache License 2.0 5 votes vote down vote up
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
private static void setColorForSwipeBack(Activity activity, @ColorInt int color,
                                         @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {
                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
 
Example 12
Source File: StackViewAnimation.java    From delion with Apache License 2.0 5 votes vote down vote up
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example 13
Source File: StackViewAnimation.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example 14
Source File: UCropFragment.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
public void setupViews(View view, Bundle args) {
    mActiveWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_background));
    mActiveControlsWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_active));
    mLogoColor = args.getInt(UCrop.Options.EXTRA_UCROP_LOGO_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_default_logo));
    mShowBottomControls = !args.getBoolean(UCrop.Options.EXTRA_HIDE_BOTTOM_CONTROLS, false);
    mRootViewBackgroundColor = args.getInt(UCrop.Options.EXTRA_UCROP_ROOT_VIEW_BACKGROUND_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_crop_background));

    initiateRootViews(view);
    callback.loadingProgress(true);

    if (mShowBottomControls) {

        ViewGroup wrapper = view.findViewById(R.id.controls_wrapper);
        wrapper.setVisibility(View.VISIBLE);
        wrapper.setBackgroundColor(mRootViewBackgroundColor);
        LayoutInflater.from(getContext()).inflate(R.layout.ucrop_controls, wrapper, true);

        mControlsTransition = new AutoTransition();
        mControlsTransition.setDuration(CONTROLS_ANIMATION_DURATION);

        mWrapperStateAspectRatio = view.findViewById(R.id.state_aspect_ratio);
        mWrapperStateAspectRatio.setOnClickListener(mStateClickListener);
        mWrapperStateRotate = view.findViewById(R.id.state_rotate);
        mWrapperStateRotate.setOnClickListener(mStateClickListener);
        mWrapperStateScale = view.findViewById(R.id.state_scale);
        mWrapperStateScale.setOnClickListener(mStateClickListener);

        mLayoutAspectRatio = view.findViewById(R.id.layout_aspect_ratio);
        mLayoutRotate = view.findViewById(R.id.layout_rotate_wheel);
        mLayoutScale = view.findViewById(R.id.layout_scale_wheel);

        setupAspectRatioWidget(args, view);
        setupRotateWidget(view);
        setupScaleWidget(view);
        setupStatesWrapper(view);
    }
}
 
Example 15
Source File: ReuseScene1.java    From scene with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected ViewGroup onCreateNewView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    SystemClock.sleep(1000);
    ViewGroup view = new FrameLayout(getActivity());
    view.setBackgroundColor(Color.YELLOW);
    return view;
}
 
Example 16
Source File: MainActivity.java    From ImageGallery with Apache License 2.0 4 votes vote down vote up
private void applyPalette(Palette palette, ViewGroup viewGroup){
    int bgColor = getBackgroundColor(palette);
    if (bgColor != -1)
        viewGroup.setBackgroundColor(bgColor);
}
 
Example 17
Source File: ExpandedControllerActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MediaNotificationUma.recordClickSource(getIntent());

    mMediaRouteController =
            RemoteMediaPlayerController.instance().getCurrentlyPlayingMediaRouteController();

    if (mMediaRouteController == null || mMediaRouteController.routeIsDefaultRoute()) {
        // We don't want to do anything for the default (local) route
        finish();
        return;
    }

    // Make the activity full screen.
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // requestWindowFeature must be called before adding content.
    setContentView(R.layout.expanded_cast_controller);
    mHandler = new Handler();

    ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content);
    rootView.setBackgroundColor(Color.BLACK);

    mMediaRouteController.addUiListener(this);

    // Create transport controller to control video, giving the callback
    // interface to receive actions from.
    mTransportMediator = new TransportMediator(this, mTransportPerformer);

    // Create and initialize the media control UI.
    mMediaController = (MediaController) findViewById(R.id.cast_media_controller);
    mMediaController.setMediaPlayer(mTransportMediator);

    View button = getLayoutInflater().inflate(R.layout.cast_controller_media_route_button,
            rootView, false);

    if (button instanceof FullscreenMediaRouteButton) {
        mMediaRouteButton = (FullscreenMediaRouteButton) button;
        rootView.addView(mMediaRouteButton);
        mMediaRouteButton.bringToFront();
        mMediaRouteButton.initialize(mMediaRouteController);
    } else {
        mMediaRouteButton = null;
    }

    // Initialize the video info.
    setVideoInfo(new RemoteVideoInfo(null, 0, RemoteVideoInfo.PlayerState.STOPPED, 0, null));

    mMediaController.refresh();

    scheduleProgressUpdate();
}
 
Example 18
Source File: GiraffePlayer.java    From GiraffePlayer2 with Apache License 2.0 4 votes vote down vote up
private ViewGroup createFloatBox() {
        removeFloatContainer();
        Activity topActivity = PlayerManager.getInstance().getTopActivity();
        ViewGroup topActivityBox = (ViewGroup) topActivity.findViewById(android.R.id.content);
        ViewGroup floatBox = (ViewGroup) LayoutInflater.from(topActivity.getApplication()).inflate(R.layout.giraffe_float_box, null);
        floatBox.setBackgroundColor(videoInfo.getBgColor());

        FrameLayout.LayoutParams floatBoxParams = new FrameLayout.LayoutParams(VideoInfo.floatView_width, VideoInfo.floatView_height);
        if (VideoInfo.floatView_x == Integer.MAX_VALUE || VideoInfo.floatView_y == Integer.MAX_VALUE) {
            floatBoxParams.gravity = Gravity.BOTTOM | Gravity.END;
            floatBoxParams.bottomMargin = 20;
            floatBoxParams.rightMargin = 20;
        } else {
            floatBoxParams.gravity = Gravity.TOP | Gravity.START;
            floatBoxParams.leftMargin = (int) VideoInfo.floatView_x;
            floatBoxParams.topMargin = (int) VideoInfo.floatView_y;
        }
        topActivityBox.addView(floatBox, floatBoxParams);

        floatBox.setOnTouchListener(new View.OnTouchListener() {
            float ry;
            float oy;

            float rx;
            float ox;

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // 获取相对屏幕的坐标,即以屏幕左上角为原点
//                System.out.println("MotionEvent:action:"+event.getAction()+",raw:["+event.getRawX()+","+event.getRawY()+"],xy["+event.getX()+","+event.getY()+"]");

                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        ry = event.getRawY();
                        oy = v.getTranslationY();

                        rx = event.getRawX();
                        ox = v.getTranslationX();
                        break;
                    case MotionEvent.ACTION_MOVE:
                        float y = oy + event.getRawY() - ry;
                        if (y > 0) {
//                            y = 0;
                        }
                        v.setTranslationY(y);

                        float x = ox + event.getRawX() - rx;
                        if (x > 0) {
//                            x = 0;
                        }
                        v.setTranslationX(x);
                        break;
                }
                return true;
            }
        });
        return floatBox;
    }
 
Example 19
Source File: UCropActivity.java    From EasyPhotos with Apache License 2.0 4 votes vote down vote up
private void setupViews(@NonNull Intent intent) {
    mStatusBarColor = intent.getIntExtra(UCrop.Options.EXTRA_STATUS_BAR_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_statusbar));
    mToolbarColor = intent.getIntExtra(UCrop.Options.EXTRA_TOOL_BAR_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_toolbar));
    mActiveWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
    mActiveControlsWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE, ContextCompat.getColor(this, R.color.ucrop_color_active_controls_color));

    mToolbarWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_WIDGET_COLOR_TOOLBAR, ContextCompat.getColor(this, R.color.ucrop_color_toolbar_widget));
    mToolbarCancelDrawable = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_WIDGET_CANCEL_DRAWABLE, R.drawable.ucrop_ic_cross);
    mToolbarCropDrawable = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_WIDGET_CROP_DRAWABLE, R.drawable.ucrop_ic_done);
    mToolbarTitle = intent.getStringExtra(UCrop.Options.EXTRA_UCROP_TITLE_TEXT_TOOLBAR);
    mToolbarTitle = mToolbarTitle != null ? mToolbarTitle : getResources().getString(R.string.ucrop_label_edit_photo);
    mLogoColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_LOGO_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_default_logo));
    mShowBottomControls = !intent.getBooleanExtra(UCrop.Options.EXTRA_HIDE_BOTTOM_CONTROLS, false);
    mRootViewBackgroundColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_ROOT_VIEW_BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_crop_background));

    setupAppBar();
    initiateRootViews();

    if (mShowBottomControls) {

        ViewGroup viewGroup = findViewById(R.id.ucrop_photobox);
        ViewGroup wrapper = viewGroup.findViewById(R.id.controls_wrapper);
        wrapper.setVisibility(View.VISIBLE);
        wrapper.setBackgroundColor(mRootViewBackgroundColor);
        LayoutInflater.from(this).inflate(R.layout.ucrop_controls, wrapper, true);

        mControlsTransition = new AutoTransition();
        mControlsTransition.setDuration(CONTROLS_ANIMATION_DURATION);

        mWrapperStateAspectRatio = findViewById(R.id.state_aspect_ratio);
        mWrapperStateAspectRatio.setOnClickListener(mStateClickListener);
        mWrapperStateRotate = findViewById(R.id.state_rotate);
        mWrapperStateRotate.setOnClickListener(mStateClickListener);
        mWrapperStateScale = findViewById(R.id.state_scale);
        mWrapperStateScale.setOnClickListener(mStateClickListener);

        mLayoutAspectRatio = findViewById(R.id.layout_aspect_ratio);
        mLayoutRotate = findViewById(R.id.layout_rotate_wheel);
        mLayoutScale = findViewById(R.id.layout_scale_wheel);

        setupAspectRatioWidget(intent);
        setupRotateWidget();
        setupScaleWidget();
        setupStatesWrapper();
    }
}
 
Example 20
Source File: CashOutFragment.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view =  inflater.inflate(R.layout.fragment_cash_out, container, false);

    ViewGroup rootView = view.findViewById(R.id.rootView);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        rootView.setBackgroundColor(Color.parseColor(WalletActivity.primaryColor));
    }
    appBar = view.findViewById(R.id.app_bar);
    appBar.setTitle(getString(isCashOut ? R.string.cash_out_paygear : R.string.charge_paygear));
    appBar.setToolBarBackgroundRes(R.drawable.app_bar_back_shape,true);
    appBar.getBack().getBackground().setColorFilter(new PorterDuffColorFilter(Color.parseColor(WalletActivity.primaryColor),PorterDuff.Mode.SRC_IN));
    appBar.showBack();

    TabLayout tabLayout = view.findViewById(R.id.tab_layout);
    mPager = view.findViewById(R.id.view_pager);
    mPagerAdapter = new WalletPagerAdapter(getChildFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    tabLayout.setupWithViewPager(mPager);

    if (isCashOut) {
        mPager.setCurrentItem(1);
    }

    for (int i = 0; i < tabLayout.getTabCount(); i++) {
        TabLayout.Tab tab = tabLayout.getTabAt(i);
        if (tab != null) {
            TextView textView = new TextView(getContext());
            textView.setId(android.R.id.text1);
            textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            textView.setTextColor(Color.WHITE);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
            textView.setTypeface(Typefaces.get(getContext(), Typefaces.IRAN_YEKAN_REGULAR));

            tab.setCustomView(textView);
        }
    }

    return view;
}