当前位置: 首页>>代码示例>>Java>>正文


Java FrameLayout.setBackgroundDrawable方法代码示例

本文整理汇总了Java中android.widget.FrameLayout.setBackgroundDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java FrameLayout.setBackgroundDrawable方法的具体用法?Java FrameLayout.setBackgroundDrawable怎么用?Java FrameLayout.setBackgroundDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.FrameLayout的用法示例。


在下文中一共展示了FrameLayout.setBackgroundDrawable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.FrameLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        postponeEnterTransition();
    }
    setContentView(R.layout.activity_destination);
    FrameLayout container = (FrameLayout) findViewById(R.id.container);
    colorDrawable = new ColorDrawable(getResources().getColor(R.color.colorPrimaryDark));
    container.setBackgroundDrawable(colorDrawable);

    Intent intent = getIntent();
    ArrayList<Uri> uris = intent.getParcelableArrayListExtra("uris");
    adapterPosition = intent.getIntExtra("adapter_position", 0);
    current = intent.getIntExtra("current", 0);

    viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setAdapter(new PhotoAdapter(uris, onDismissListener));
    viewPager.setCurrentItem(current);
}
 
开发者ID:mingdroid,项目名称:SETransitionDemo,代码行数:22,代码来源:DestinationActivity.java

示例2: onViewCreated

import android.widget.FrameLayout; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    container = (FrameLayout) view;
    containerLayoutParams = new FrameLayout.LayoutParams(getWidth(), getHeight());
    container.setBackgroundDrawable(alertDrawable);
}
 
开发者ID:nidhinvv,项目名称:BubbleAlert,代码行数:8,代码来源:BblDialogFragmentBase.java

示例3: redrawCurrentStationLineIcons

import android.widget.FrameLayout; //导入方法依赖的package包/类
private void redrawCurrentStationLineIcons(Station station) {
    curStationIconsLayout.removeAllViews();
    List<Line> lines = new ArrayList<>(station.getLines());
    Collections.sort(lines, new Comparator<Line>() {
        @Override
        public int compare(Line l1, Line l2) {
            return l1.getName().compareTo(l2.getName());
        }
    });

    for (Line l : lines) {
        Drawable drawable = ContextCompat.getDrawable(getContext(), Util.getDrawableResourceIdForLineId(l.getId()));
        drawable.setColorFilter(l.getColor(), PorterDuff.Mode.SRC_ATOP);

        int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
        FrameLayout iconFrame = new FrameLayout(getContext());
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(height, height);
        int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            params.setMarginEnd(margin);
        }
        int marginTop = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
        params.setMargins(0, marginTop, margin, 0);
        iconFrame.setLayoutParams(params);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            iconFrame.setBackgroundDrawable(drawable);
        } else {
            iconFrame.setBackground(drawable);
        }
        curStationIconsLayout.addView(iconFrame);
    }
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:33,代码来源:HomeFragment.java

示例4: initPageView

import android.widget.FrameLayout; //导入方法依赖的package包/类
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);
	flPage.setBackgroundDrawable(new ColorDrawable(0x55000000));

	// container of the platform gridview
	llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	llPage.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// gridview
	grid = new PlatformGridView(getContext());
	grid.setEditPageBackground(getBackgroundView());
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xff3a65ff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	int resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, com.mob.tools.utils.R.dipToPx(getContext(), 5));

	resId = getBitmapRes(getContext(), "classic_platform_corners_bg");
	if(resId > 0){
		btnCancel.setBackgroundResource(resId);
	}else {
	    btnCancel.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	}

	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, com.mob.tools.utils.R.dipToPx(getContext(), 45));
	int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:52,代码来源:PlatformListPage.java

示例5: TrashView

import android.widget.FrameLayout; //导入方法依赖的package包/类
/**
 * コンストラクタ
 *
 * @param context Context
 */
TrashView(Context context) {
    super(context);
    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    mMetrics = new DisplayMetrics();
    mWindowManager.getDefaultDisplay().getMetrics(mMetrics);
    mAnimationHandler = new AnimationHandler(this);
    mIsEnabled = true;

    mParams = new WindowManager.LayoutParams();
    mParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    mParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
    mParams.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
    mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
    mParams.format = PixelFormat.TRANSLUCENT;
    // INFO:Windowの原点のみ左下に設定
    mParams.gravity = Gravity.LEFT | Gravity.BOTTOM;

    // 各種Viewの設定
    // TrashViewに直接貼り付けられるView(このViewを介さないと、削除Viewと背景Viewのレイアウトがなぜか崩れる)
    mRootView = new FrameLayout(context);
    mRootView.setClipChildren(false);
    // 削除アイコンのルートView
    mTrashIconRootView = new FrameLayout(context);
    mTrashIconRootView.setClipChildren(false);
    mFixedTrashIconView = new ImageView(context);
    mActionTrashIconView = new ImageView(context);
    // 背景View
    mBackgroundView = new FrameLayout(context);
    mBackgroundView.setAlpha(0.0f);
    final GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{0x00000000, 0x50000000});
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        //noinspection deprecation
        mBackgroundView.setBackgroundDrawable(gradientDrawable);
    } else {
        mBackgroundView.setBackground(gradientDrawable);
    }

    // 背景Viewの貼り付け
    final FrameLayout.LayoutParams backgroundParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (BACKGROUND_HEIGHT * mMetrics.density));
    backgroundParams.gravity = Gravity.BOTTOM;
    mRootView.addView(mBackgroundView, backgroundParams);
    // アクションアイコンの貼り付け
    final FrameLayout.LayoutParams actionTrashIconParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    actionTrashIconParams.gravity = Gravity.CENTER;
    mTrashIconRootView.addView(mActionTrashIconView, actionTrashIconParams);
    // 固定アイコンの貼付け
    final FrameLayout.LayoutParams fixedTrashIconParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    fixedTrashIconParams.gravity = Gravity.CENTER;
    mTrashIconRootView.addView(mFixedTrashIconView, fixedTrashIconParams);
    // 削除アイコンの貼り付け
    final FrameLayout.LayoutParams trashIconParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    trashIconParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    mRootView.addView(mTrashIconRootView, trashIconParams);

    // TrashViewに貼り付け
    addView(mRootView);

    // 初回描画処理用
    getViewTreeObserver().addOnPreDrawListener(this);
}
 
开发者ID:cheenid,项目名称:FLFloatingButton,代码行数:68,代码来源:TrashView.java

示例6: onServiceConnected

import android.widget.FrameLayout; //导入方法依赖的package包/类
@Override
public void onServiceConnected(ComponentName className,
                               IBinder service) {
    // We've bound to LocalService, cast the IBinder and get LocalService instance
    binder = (MainService.LocalBinder) service;
    mainService = binder.getService();
    locBound = true;

    Network net = mainService.getNetwork(networkId);
    Line line = net.getLine(lineId);

    String title = String.format(getString(R.string.act_line_title), line.getName());
    setTitle(title);
    getSupportActionBar().setTitle(title);
    AppBarLayout abl = (AppBarLayout) findViewById(R.id.app_bar);
    final CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    ctl.setTitle(title);

    int color = line.getColor();
    ctl.setContentScrimColor(color);
    ctl.setStatusBarScrimColor(color);
    abl.setBackgroundColor(color);

    Drawable drawable = ContextCompat.getDrawable(LineActivity.this, Util.getDrawableResourceIdForLineId(line.getId()));
    drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);

    int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, getResources().getDisplayMetrics());
    FrameLayout iconFrame = new FrameLayout(LineActivity.this);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(height, height);
    int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        params.setMarginEnd(margin);
    }
    params.setMargins(0, 0, margin, 0);
    iconFrame.setLayoutParams(params);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        iconFrame.setBackgroundDrawable(drawable);
    } else {
        iconFrame.setBackground(drawable);
    }
    lineIconsLayout.addView(iconFrame);

    abl.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (ctl.getHeight() + verticalOffset < 2.5 * ViewCompat.getMinimumHeight(ctl)) {
                lineIconsLayout.animate().alpha(0);
            } else {
                lineIconsLayout.animate().alpha(1);
            }
        }
    });

    Map<String, LineStatusCache.Status> statuses = mainService.getLineStatusCache().getLineStatus();
    if (statuses.get(line.getId()) != null &&
            statuses.get(line.getId()).down) {
        disturbancesWarningLayout.setVisibility(View.VISIBLE);
    } else {
        disturbancesWarningLayout.setVisibility(View.GONE);
    }

    LinearLayout closedLayout = (LinearLayout) findViewById(R.id.closed_info_layout);
    if (line.isExceptionallyClosed(new Date())) {
        TextView closedView = (TextView) findViewById(R.id.closed_info_view);
        Formatter f = new Formatter();
        DateUtils.formatDateRange(LineActivity.this, f, line.getNextOpenTime(), line.getNextOpenTime(), DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
        closedView.setText(String.format(getString(R.string.act_line_closed_schedule), f.toString()));


        closedLayout.setVisibility(View.VISIBLE);
    } else {
        closedLayout.setVisibility(View.GONE);
    }

    populateLineView(LineActivity.this, getLayoutInflater(), net, line, lineLayout);
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:77,代码来源:LineActivity.java


注:本文中的android.widget.FrameLayout.setBackgroundDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。