android.widget.LinearLayout#setBackgroundColor ( )源码实例Demo

下面列出了android.widget.LinearLayout#setBackgroundColor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: YImagePicker   文件: ImagesViewPager.java
/**
 * 普通样式
 */
public void style1() {
    isStyle1 = true;
    removeAllViews();
    viewPager = new ViewPager(getContext());
    addView(viewPager, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    indicatorLayout = new LinearLayout(getContext());
    indicatorLayout.setGravity(Gravity.CENTER);
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(CENTER_HORIZONTAL);
    params.addRule(ALIGN_PARENT_BOTTOM);
    params.addRule(BELOW, viewPager.getId());
    indicatorLayout.setPadding(0, dp(8), 0, dp(8));
    indicatorLayout.setBackgroundColor(Color.TRANSPARENT);
    addView(indicatorLayout, params);

    circleImageIndicator = new CircleImageIndicator(getContext());
    circleImageIndicator.setBackgroundColor(Color.TRANSPARENT);
    circleImageIndicator.setNormalColor(Color.RED);
    circleImageIndicator.setPressColor(Color.GREEN);
    circleImageIndicator.setBlendColors(true);
    indicatorLayout.addView(circleImageIndicator, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    circleImageIndicator.bindViewPager(viewPager);
}
 
源代码2 项目: drupalfit   文件: WebDialog.java
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    Log8.d();
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    //webView.setWebChromeClient(new WebChromeClient());

    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setSaveFormData(false);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    webViewContainer.setBackgroundColor(0xCC000000);
    contentFrameLayout.addView(webViewContainer);
    Log8.d();
}
 
源代码3 项目: RichEditorView   文件: LuBottomMenu.java
/**
 * 增加一行菜单当未超过最大限制并且不是逻辑树中的叶子节点时
 */
private void addOneLevel() {
    if (mCurMenuItem == null || mCurMenuItem.isLeafNode() || mCurMenuItem.getDeep() >= MAX_LEVELS - 1) {
        return;
    }
    LinearLayout linearLayout = new LinearLayout(getContext());
    if (mTheme == null) {
        createDefaultTheme();
    }

    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setBackgroundColor(getColorByDeep(mCurMenuItem.getDeep()));
    linearLayout.setPadding(INNER_LAYOUT_PADDING_L, INNER_LAYOUT_PADDING_T,
            INNER_LAYOUT_PADDING_R, INNER_LAYOUT_PADDING_B);
    linearLayout.setLayoutParams(new ViewGroup.MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    mDisplayMenus.add(linearLayout);
    fillMenu(linearLayout, mCurMenuItem);
    addView(linearLayout);
    mPathRecord.push(mCurMenuItem);
    if (mCurMenuItem != null && !mCurMenuItem.equals(mMenuTree.getRootItem())) {
        getBottomMenuItem(mCurMenuItem).setSelected(true);
    }
    mDisplayRowNum++;
}
 
源代码4 项目: Ruisi   文件: MyGuildView.java
private void init(Context context) {
    this.context = context;
    dotMargine = DimenUtils.dip2px(context, 2);
    containerPaddingTB = DimenUtils.dip2px(context, 8);
    containerPaddingLR = DimenUtils.dip2px(context, 12);

    dotImageResourseId = R.drawable.dot_bg;
    viewPager = new ViewPager(context);
    viewPager.setLayoutParams(new LayoutParams(RMP, RMP));
    viewPager.addOnPageChangeListener(this);
    adapter = new PageAdapter();
    viewPager.setPageTransformer(true, new ScalePageTransformer());
    viewPager.setAdapter(adapter);
    addView(viewPager);

    dotContainer = new LinearLayout(context);
    LayoutParams lp = new LayoutParams(RMP, RWC);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    // 在这儿设置圆点位置
    lp.addRule(CENTER_HORIZONTAL);
    dotContainer.setLayoutParams(lp);
    dotContainer.setOrientation(LinearLayout.HORIZONTAL);
    //dotContainer.setGravity(CENTER_HORIZONTAL);
    dotContainer.setGravity(CENTER_VERTICAL);
    dotContainer.setBackgroundColor(0x7f333333);
    dotContainer.setPadding(containerPaddingLR, containerPaddingTB, containerPaddingLR, containerPaddingTB);
    addView(dotContainer);

    mAutoPlayTask = new AutoPlayTask(this);
}
 
源代码5 项目: UltraViewPager   文件: UltraPagerAdapter.java
@Override
    public Object instantiateItem(ViewGroup container, int position) {
        LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(container.getContext()).inflate(R.layout.layout_child, null);
        //new LinearLayout(container.getContext());
        TextView textView = (TextView) linearLayout.findViewById(R.id.pager_textview);
        textView.setText(position + "");
        linearLayout.setId(R.id.item_id);
        switch (position) {
            case 0:
                linearLayout.setBackgroundColor(Color.parseColor("#2196F3"));
                break;
            case 1:
                linearLayout.setBackgroundColor(Color.parseColor("#673AB7"));
                break;
            case 2:
                linearLayout.setBackgroundColor(Color.parseColor("#009688"));
                break;
            case 3:
                linearLayout.setBackgroundColor(Color.parseColor("#607D8B"));
                break;
            case 4:
                linearLayout.setBackgroundColor(Color.parseColor("#F44336"));
                break;
        }
        container.addView(linearLayout);
//        linearLayout.getLayoutParams().width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, container.getContext().getResources().getDisplayMetrics());
//        linearLayout.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, container.getContext().getResources().getDisplayMetrics());
        return linearLayout;
    }
 
源代码6 项目: AndroidLinkup   文件: RankActivity.java
/**
 * 初始化游戏等级
 */
private void initRank() {

    LinearLayout root = (LinearLayout) RankActivity.this.findViewById(R.id.rankBg);

    int index = getIntent().getIntExtra("modeIndex", 0);
    if (index != modeIndex) {
        rankCfgs = modeCfgs.get(index).getRankInfos();
    }
    // root.setBackgroundResource(ViewSettings.GameBgImageIds[rankCfgs.get(0).getRankBackground()]);
    root.setBackgroundColor(getResources().getColor(ViewSettings.RankBgColors[rankCfgs.get(0).getRankBackground()]));
}
 
源代码7 项目: Shield   文件: ControlButtonAgent.java
@Override
public View onCreateView(ViewGroup parent, int viewType) {
    LinearLayout rootView = new LinearLayout(mContext);
    rootView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    rootView.setOrientation(LinearLayout.VERTICAL);
    rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));

   // View containView = LinearLayout.inflate(getContext(), R.layout.agent_status_loading, null);
    View containView = LayoutInflater.from(getContext()).inflate(R.layout.agent_status_loading,rootView,false);
            setLoadingStatus(containView);
    rootView.addView(containView);

    return rootView;
}
 
源代码8 项目: enjoyshop   文件: EditPageLand.java
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
	llBottom.addView(v, lp);
}
 
源代码9 项目: Social   文件: EditPagePort.java
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px_1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
	llBottom.addView(v, lp);
}
 
源代码10 项目: RxTools-master   文件: ColorPickerView.java
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
    if (colorPreview == null)
        return;
    this.colorPreview = colorPreview;
    if (selectedColor == null)
        selectedColor = 0;
    int children = colorPreview.getChildCount();
    if (children == 0 || colorPreview.getVisibility() != View.VISIBLE)
        return;

    for (int i = 0; i < children; i++) {
        View childView = colorPreview.getChildAt(i);
        if (!(childView instanceof LinearLayout))
            continue;
        LinearLayout childLayout = (LinearLayout) childView;
        if (i == selectedColor) {
            childLayout.setBackgroundColor(Color.WHITE);
        }
        ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview);
        childImage.setClickable(true);
        childImage.setTag(i);
        childImage.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v == null)
                    return;
                Object tag = v.getTag();
                if (tag == null || !(tag instanceof Integer))
                    return;
                setSelectedColor((int) tag);
            }
        });
    }
}
 
源代码11 项目: styT   文件: ColorPickerView.java
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
    if (colorPreview == null)
        return;
    this.colorPreview = colorPreview;
    if (selectedColor == null)
        selectedColor = 0;
    int children = colorPreview.getChildCount();
    if (children == 0 || colorPreview.getVisibility() != View.VISIBLE)
        return;

    for (int i = 0; i < children; i++) {
        View childView = colorPreview.getChildAt(i);
        if (!(childView instanceof LinearLayout))
            continue;
        LinearLayout childLayout = (LinearLayout) childView;
        if (i == selectedColor) {
            childLayout.setBackgroundColor(Color.WHITE);
        }
        ImageView childImage = childLayout.findViewById(R.id.image_preview);
        childImage.setClickable(true);
        childImage.setTag(i);
        childImage.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v == null)
                    return;
                Object tag = v.getTag();
                if (tag == null || !(tag instanceof Integer))
                    return;
                setSelectedColor((int) tag);
            }
        });
    }
}
 
源代码12 项目: LQRWeChat   文件: EditPageLand.java
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
	llBottom.addView(v, lp);
}
 
源代码13 项目: openScale   文件: ChartActionBarView.java
private void init() {
    actionBarView = new LinearLayout(getContext());
    actionBarView.setOrientation(LinearLayout.HORIZONTAL);
    actionBarView.setBackgroundColor(ColorUtil.COLOR_BLACK);

    measurementViews = MeasurementView.getMeasurementList(
            getContext(), MeasurementView.DateTimeOrder.NONE);

    isInGraphKey = true;
    onActionClickListener = null;

    addView(actionBarView);
    refreshFloatingActionsButtons();
}
 
源代码14 项目: MaterialQQLite   文件: ChatActivity.java
@SuppressLint("NewApi")
    private void initView() {
    //    m_txtName = (TextView)findViewById(R.id.chat_txtName);
        m_lvMsg = (ListView)findViewById(R.id.chat_lvMsg);
        swipeRefreshLayout_chat= (PullRefreshLayout) findViewById(R.id.swipeRefreshLayout_chat);
        m_btnFace = (ImageButton)findViewById(R.id.chat_btnFace);
    //    m_btnMore = (ImageButton)findViewById(R.id.chat_btnMore);
        m_edtMsg = (EditText) findViewById(R.id.chat_edtMsg);
        m_btnSend = (Button) findViewById(R.id.chat_btnSend);
        m_faceBar = findViewById(R.id.chat_facebar);
        m_vpFace = (ViewPager)findViewById(R.id.chat_vpFace);
        m_dotBar = (LinearLayout) findViewById(R.id.chat_dotbar);



        m_btnFace.setOnClickListener(this);
        m_edtMsg.setOnClickListener(this);
        m_btnSend.setOnClickListener(this);

        if (m_nType != IS_GROUP)
          //  m_txtName.setText(m_strBuddyName);
            m_txtName=m_strBuddyName;
        else
         //   m_txtName.setText(m_strGroupName);
        m_txtName=m_strGroupName;

        initChatMsgListView();	// 初始化聊天消息列表框
        initFaceBar();			// 初始化表情栏

        m_nCurFacePage = 0;
        m_vpFace.setCurrentItem(1);

        toolbar = (Toolbar) findViewById(R.id.toolbar_chat);
        toolbar.setNavigationIcon(R.drawable.qqicon);
        toolbar.setTitle(m_txtName);

        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        chat_inputbar= (LinearLayout) findViewById(R.id.chat_inputbar);

        toolbar.setBackgroundColor(color_theme);
        chat_inputbar.setBackgroundColor(color_theme);

        // 去除 ListView 上下边界蓝色或黄色阴影
//		ListView actualListView = m_lvMsg.getRefreshableView();
//		if (Integer.parseInt(Build.VERSION.SDK) >= 9) {
//			actualListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
//        }
    }
 
源代码15 项目: Memory-capsule   文件: DatePicker.java
public DatePicker(Context context, AttributeSet attrs) {
    super(context, attrs);
    mTManager = DPTManager.getInstance();
    mLManager = DPLManager.getInstance();

    // 设置排列方向为竖向
    setOrientation(VERTICAL);

    LayoutParams llParams =
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    // 标题栏根布局
    RelativeLayout rlTitle = new RelativeLayout(context);
    rlTitle.setBackgroundColor(mTManager.colorTitleBG());
    int rlTitlePadding = MeasureUtil.dp2px(context, 10);
    rlTitle.setPadding(rlTitlePadding, rlTitlePadding, rlTitlePadding, rlTitlePadding);

    // 周视图根布局
    LinearLayout llWeek = new LinearLayout(context);
    llWeek.setBackgroundColor(mTManager.colorTitleBG());
    llWeek.setOrientation(HORIZONTAL);
    int llWeekPadding = MeasureUtil.dp2px(context, 5);
    llWeek.setPadding(0, llWeekPadding, 0, llWeekPadding);
    LayoutParams lpWeek = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    lpWeek.weight = 1;

    // 标题栏子元素布局参数
    RelativeLayout.LayoutParams lpYear =
            new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    lpYear.addRule(RelativeLayout.CENTER_VERTICAL);
    RelativeLayout.LayoutParams lpMonth =
            new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    lpMonth.addRule(RelativeLayout.CENTER_IN_PARENT);
    RelativeLayout.LayoutParams lpEnsure =
            new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    lpEnsure.addRule(RelativeLayout.CENTER_VERTICAL);
    lpEnsure.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    // --------------------------------------------------------------------------------标题栏
    // 年份显示
    tvYear = new TextView(context);
    tvYear.setText("2015");
    tvYear.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    tvYear.setTextColor(mTManager.colorTitle());

    // 月份显示
    tvMonth = new TextView(context);
    tvMonth.setText("六月");
    tvMonth.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    tvMonth.setTextColor(mTManager.colorTitle());

    // 确定显示
    tvEnsure = new TextView(context);
    tvEnsure.setText(mLManager.titleEnsure());
    tvEnsure.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    tvEnsure.setTextColor(mTManager.colorTitle());
    tvEnsure.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != onDateSelectedListener) {
                onDateSelectedListener.onDateSelected(monthView.getDateSelected());
            }
        }
    });

    rlTitle.addView(tvYear, lpYear);
    rlTitle.addView(tvMonth, lpMonth);
    rlTitle.addView(tvEnsure, lpEnsure);

    addView(rlTitle, llParams);

    // --------------------------------------------------------------------------------周视图
    for (int i = 0; i < mLManager.titleWeek().length; i++) {
        TextView tvWeek = new TextView(context);
        tvWeek.setText(mLManager.titleWeek()[i]);
        tvWeek.setGravity(Gravity.CENTER);
        tvWeek.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
        tvWeek.setTextColor(mTManager.colorTitle());
        llWeek.addView(tvWeek, lpWeek);
    }
    addView(llWeek, llParams);

    // ------------------------------------------------------------------------------------月视图
    monthView = new MonthView(context);
    monthView.setOnDateChangeListener(new MonthView.OnDateChangeListener() {
        @Override
        public void onMonthChange(int month) {
            tvMonth.setText(mLManager.titleMonth()[month - 1]);
        }

        @Override
        public void onYearChange(int year) {
            String tmp = String.valueOf(year);
            if (tmp.startsWith("-")) {
                tmp = tmp.replace("-", mLManager.titleBC());
            }
            tvYear.setText(tmp);
        }
    });
    addView(monthView, llParams);
}
 
源代码16 项目: Float-Bar   文件: DrawService.java
/**
 * 更新悬浮窗布局等
 */
private void updateUi() {
	RIGHT_MODE = !prefs.getDrawMode();
	DRAW_COLOR = prefs.getDrawColor();
	ALPHA = prefs.getDrawAlpha();

	// 获取浮动窗口视图所在布局
	layout = (LinearLayout) inflater.inflate(RIGHT_MODE ? R.layout.draw_right : R.layout.draw_left, null);
	// 添加悬浮窗的视图
	mWindowManager.addView(layout, wmParams);

	/**
	 * 设置抽屉控件的打开方向和监听器
	 */
	mDrawerLayout = (DrawerLayout) layout.findViewById(R.id.drawer_layout);
	mDrawerLayout.setDrawerListener(new MyDrawListener());
	mDrawerLayout.openDrawer(RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT);

	/**
	 * 设置上方的home键
	 */
	Button home = (Button) layout.findViewById(R.id.home_key);
	home.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			Util.virtualHome(getBaseContext());
			stopSelf();
		}
	});

	/**
	 * 设置抽屉控件内的背景
	 */
	drawContent = (LinearLayout) layout.findViewById(R.id.drawer_content);
	drawContent.setBackgroundColor(DRAW_COLOR);
	drawContent.getBackground().setAlpha(ALPHA);

	/**
	 * 设置最近任务list中item的个数:20
	 */
	Util.reloadButtons(this, appInfos, 20);
	ListView listView = (ListView) layout.findViewById(R.id.drawer_list);
	listView.setAdapter(new AppAdapter(this, mWindowManager, layout, mDrawerLayout, appInfos));

	// 悬浮窗显示确定右上角为起始坐标
	wmParams.gravity = RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT | Gravity.TOP;
	// 以屏幕右上角为原点,设置x、y初始值,确定显示窗口的起始位置
	// 添加动画。参考自:http://bbs.9ria.com/thread-242912-1-1.html
	wmParams.windowAnimations = (RIGHT_MODE) ? R.style.right_anim : R.style.left_anim;

	mWindowManager.updateViewLayout(layout, wmParams);
}
 
源代码17 项目: NetCloud_android   文件: AppConnectionsWindow.java
public ItemView(Context context) {
    super(context);

    mContent = new LinearLayout(context);
    mContent.setOrientation(LinearLayout.HORIZONTAL);
    mContent.setGravity(Gravity.CENTER_VERTICAL);
    mContent.setBackgroundColor(Color.TRANSPARENT);
    mProtocol = new TextView(context);
    int iconSize = (int)ResTools.getDimen(R.dimen.icon_size);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(iconSize, iconSize);
    lp.rightMargin = (int)ResTools.getDimen(R.dimen.hor_padding);
    mProtocol.setLayoutParams(lp);
    mContent.addView(mProtocol);

    mInfo = new LinearLayout(context);
    mInfo.setOrientation(LinearLayout.VERTICAL);


    int textsize = (int)ResTools.getDimen(R.dimen.textsize2);
    int textsize1 = (int)ResTools.getDimen(R.dimen.textsize3);
    mDest = new TextView(context);
    mDest.setTextSize(TypedValue.COMPLEX_UNIT_PX, textsize);
    mDest.setTextColor(ResTools.getColor(R.color.text));
    mInfo.addView(mDest);

    mTraffic = new TextView(context);
    mTraffic.setTextSize(TypedValue.COMPLEX_UNIT_PX, textsize1);
    mTraffic.setTextColor(ResTools.getColor(R.color.text1));
    lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.topMargin = ScreenUtils.dp2px(8);
    mInfo.addView(mTraffic,lp);

    mTime = new TextView(context);
    mTime.setTextSize(TypedValue.COMPLEX_UNIT_PX, textsize1);
    mTime.setTextColor(ResTools.getColor(R.color.text1));
    lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.topMargin = ScreenUtils.dp2px(3);
    mInfo.addView(mTime);

    lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.weight = 1;
    mContent.addView(mInfo,lp);

    mState = new TextView(context);
    mState.setTextSize(TypedValue.COMPLEX_UNIT_PX, textsize);
    mState.setGravity(Gravity.TOP|Gravity.RIGHT);
    mState.setTextColor(ResTools.getColor(R.color.text));
    mContent.addView(mState);

    addView(mContent, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    mMask = new View(context);
    mMask.setFocusable(false);
    mMask.setFocusableInTouchMode(false);
    mMask.setBackgroundResource(R.drawable.list_item_normal_died);
    addView(mMask, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    setBackgroundResource(R.drawable.list_item_normal);

    int hp = (int)ResTools.getDimen(R.dimen.hor_padding);
    int vp = (int)ResTools.getDimen(R.dimen.vtl_padding);
    mContent.setPadding(hp,vp,hp,vp);

    setOnClickListener(this);

    mDate = new Date();
    mFormat = new SimpleDateFormat("HH:mm:ss:SSS");
}
 
源代码18 项目: Android-PickerView   文件: OptionsPickerView.java
private void initView(Context context) {
    setDialogOutSideCancelable();
    initViews();
    initAnim();
    initEvents();
    if (mPickerOptions.customListener == null) {
        LayoutInflater.from(context).inflate(mPickerOptions.layoutRes, contentContainer);

        //顶部标题
        TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
        RelativeLayout rv_top_bar = (RelativeLayout) findViewById(R.id.rv_topbar);

        //确定和取消按钮
        Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        Button btnCancel = (Button) findViewById(R.id.btnCancel);

        btnSubmit.setTag(TAG_SUBMIT);
        btnCancel.setTag(TAG_CANCEL);
        btnSubmit.setOnClickListener(this);
        btnCancel.setOnClickListener(this);

        //设置文字
        btnSubmit.setText(TextUtils.isEmpty(mPickerOptions.textContentConfirm) ? context.getResources().getString(R.string.pickerview_submit) : mPickerOptions.textContentConfirm);
        btnCancel.setText(TextUtils.isEmpty(mPickerOptions.textContentCancel) ? context.getResources().getString(R.string.pickerview_cancel) : mPickerOptions.textContentCancel);
        tvTitle.setText(TextUtils.isEmpty(mPickerOptions.textContentTitle) ? "" : mPickerOptions.textContentTitle);//默认为空

        //设置color
        btnSubmit.setTextColor(mPickerOptions.textColorConfirm);
        btnCancel.setTextColor(mPickerOptions.textColorCancel);
        tvTitle.setTextColor(mPickerOptions.textColorTitle);
        rv_top_bar.setBackgroundColor(mPickerOptions.bgColorTitle);

        //设置文字大小
        btnSubmit.setTextSize(mPickerOptions.textSizeSubmitCancel);
        btnCancel.setTextSize(mPickerOptions.textSizeSubmitCancel);
        tvTitle.setTextSize(mPickerOptions.textSizeTitle);
    } else {
        mPickerOptions.customListener.customLayout(LayoutInflater.from(context).inflate(mPickerOptions.layoutRes, contentContainer));
    }

    // ----滚轮布局
    final LinearLayout optionsPicker = (LinearLayout) findViewById(R.id.optionspicker);
    optionsPicker.setBackgroundColor(mPickerOptions.bgColorWheel);

    wheelOptions = new WheelOptions<>(optionsPicker, mPickerOptions.isRestoreItem);
    if (mPickerOptions.optionsSelectChangeListener != null) {
        wheelOptions.setOptionsSelectChangeListener(mPickerOptions.optionsSelectChangeListener);
    }

    wheelOptions.setTextContentSize(mPickerOptions.textSizeContent);
    wheelOptions.setItemsVisible(mPickerOptions.itemsVisibleCount);
    wheelOptions.setAlphaGradient(mPickerOptions.isAlphaGradient);
    wheelOptions.setLabels(mPickerOptions.label1, mPickerOptions.label2, mPickerOptions.label3);
    wheelOptions.setTextXOffset(mPickerOptions.x_offset_one, mPickerOptions.x_offset_two, mPickerOptions.x_offset_three);
    wheelOptions.setCyclic(mPickerOptions.cyclic1, mPickerOptions.cyclic2, mPickerOptions.cyclic3);
    wheelOptions.setTypeface(mPickerOptions.font);

    setOutSideCancelable(mPickerOptions.cancelable);

    wheelOptions.setDividerColor(mPickerOptions.dividerColor);
    wheelOptions.setDividerType(mPickerOptions.dividerType);
    wheelOptions.setLineSpacingMultiplier(mPickerOptions.lineSpacingMultiplier);
    wheelOptions.setTextColorOut(mPickerOptions.textColorOut);
    wheelOptions.setTextColorCenter(mPickerOptions.textColorCenter);
    wheelOptions.isCenterLabel(mPickerOptions.isCenterLabel);
}
 
源代码19 项目: Huochexing12306   文件: FollowList.java
public void onCreate() {
	LinearLayout llPage = new LinearLayout(getContext());
	llPage.setBackgroundColor(0xfff5f5f5);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	// 标题栏
	llTitle = new TitleLayout(getContext());
	int resId = getBitmapRes(getContext(), "title_back");
	if (resId > 0) {
		llTitle.setBackgroundResource(resId);
	}
	llTitle.getBtnBack().setOnClickListener(this);
	resId = getStringRes(getContext(), "multi_share");
	if (resId > 0) {
		llTitle.getTvTitle().setText(resId);
	}
	llTitle.getBtnRight().setVisibility(View.VISIBLE);
	resId = getStringRes(getContext(), "finish");
	if (resId > 0) {
		llTitle.getBtnRight().setText(resId);
	}
	llTitle.getBtnRight().setOnClickListener(this);
	llTitle.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	llPage.addView(llTitle);

	FrameLayout flPage = new FrameLayout(getContext());
	LinearLayout.LayoutParams lpFl = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpFl.weight = 1;
	flPage.setLayoutParams(lpFl);
	llPage.addView(flPage);

	// 关注(或朋友)列表
	PullToRefreshView followList = new PullToRefreshView(getContext());
	FrameLayout.LayoutParams lpLv = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	followList.setLayoutParams(lpLv);
	flPage.addView(followList);
	adapter = new FollowAdapter(followList);
	adapter.setPlatform(platform);
	followList.setAdapter(adapter);
	adapter.getListView().setOnItemClickListener(this);

	ImageView ivShadow = new ImageView(getContext());
	resId = getBitmapRes(getContext(), "title_shadow");
	if (resId > 0) {
		ivShadow.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpSd = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	ivShadow.setLayoutParams(lpSd);
	flPage.addView(ivShadow);

	// 请求数据
	followList.performPulling(true);
}
 
源代码20 项目: enjoyshop   文件: PlatformPage.java
public void onCreate() {
    //		activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000));
    initAnims();

    LinearLayout llPage = new LinearLayout(activity);
    llPage.setOrientation(LinearLayout.VERTICAL);
    activity.setContentView(llPage);

    TextView vTop = new TextView(activity);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.weight = 1;
    vTop.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
    llPage.addView(vTop, lp);

    llPanel = new LinearLayout(activity);
    llPanel.setOrientation(LinearLayout.VERTICAL);
    lp = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    llPanel.setAnimation(animShow);
    llPage.addView(llPanel, lp);

    MobViewPager mvp = new MobViewPager(activity);
    ArrayList<Object> cells = collectCells();
    PlatformPageAdapter adapter = newAdapter(cells);
    lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getPanelHeight());
    llPanel.addView(mvp, lp);

    IndicatorView vInd = new IndicatorView(activity);
    lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getBottomHeight());
    llPanel.addView(vInd, lp);

    vInd.setScreenCount(adapter.getCount());
    vInd.onScreenChange(0, 0);
    adapter.setIndicator(vInd);
    mvp.setAdapter(adapter);


    /**
     * 添加 取消分享按钮
     */

    lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 150);
    lp.setMargins(0, 0, 0, 0);
    LinearLayout buttonLayout2 = new LinearLayout(activity);
    buttonLayout2.setBackgroundColor(Color.WHITE);

    LinearLayout.LayoutParams lp22 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams
            .MATCH_PARENT, 110);
    lp22.setMargins(20, 20, 20, 20);
    //        Button button2 = new Button(activity);
    //        button2.setText("取消分享");
    //        button2.setTextSize(16);
    //        button2.setTextColor(Color.BLACK);
    //        button2.setBackgroundColor(Color.GREEN);
    //        button2.setOnClickListener(new OnClickListener() {
    //
    //            @Override
    //            public void onClick(View v) {
    //                finish();
    //            }
    //        });
    //
    //
    //        buttonLayout2.addView(button2, lp22);
    //        llPanel.addView(buttonLayout2, lp);


    ImageView imgView = getImageView();
    imgView.setImageResource(R.drawable.icon_delete_32);
    imgView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    buttonLayout2.addView(imgView, lp22);
    llPanel.addView(buttonLayout2, lp);

}