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

The following examples show how to use android.widget.RelativeLayout#setBackgroundDrawable() . 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: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
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: 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 4
Source File: EditPage.java    From AndroidLinkup with GNU General Public License v2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 5
Source File: EditPage.java    From ShareSDKShareDifMsgDemo-Android with MIT License 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 6
Source File: EditPage.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 7
Source File: WeiboDialog.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void initWebView()
{
    mWebViewContainer = new RelativeLayout(getContext());
    mWebView = new WebView(getContext());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setSavePassword(false);
    mWebView.setWebViewClient(new WeiboWebViewClient(null));
    mWebView.requestFocus();
    mWebView.setScrollBarStyle(0);
    mWebView.setVisibility(4);
    NetworkHelper.clearCookies(mContext, mAuthUrl);
    mWebView.loadUrl(mAuthUrl);
    android.widget.RelativeLayout.LayoutParams layoutparams = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    android.widget.RelativeLayout.LayoutParams layoutparams1 = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    DisplayMetrics displaymetrics = getContext().getResources().getDisplayMetrics();
    int i = (int)(10F * displaymetrics.density);
    layoutparams1.setMargins(i, i, i, i);
    Drawable drawable = ResourceManager.getNinePatchDrawable(mContext, 1);
    mWebViewContainer.setBackgroundDrawable(drawable);
    mWebViewContainer.addView(mWebView, layoutparams1);
    mWebViewContainer.setGravity(17);
    int j = 1 + ResourceManager.getDrawable(mContext, 2).getIntrinsicWidth() / 2;
    layoutparams.setMargins(j, (int)(25F * displaymetrics.density), j, j);
    mRootContainer.addView(mWebViewContainer, layoutparams);
}
 
Example 8
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 9
Source File: EditPage.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 10
Source File: MongolToast.java    From mongol-library with MIT License 5 votes vote down vote up
private View getLayout() {
    int horizontalPadding = (int) getTypedValueInDP(context, DEFAULT_HORIZONTAL_PADDING);
    int verticalPadding = (int) getTypedValueInDP(context, DEFAULT_VERTICAL_PADDING);
    RelativeLayout rootLayout = new RelativeLayout(context);
    rootLayout.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
    rootLayout.setBackgroundDrawable(getShape());
    rootLayout.addView(getTextView());
    return rootLayout;
}
 
Example 11
Source File: FragmentNavigationDrawer.java    From Rumble with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mDrawerFragmentLayout = (LinearLayout) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);

    /* set the header */
    localContact = Contact.getLocalContact();
    RelativeLayout header = (RelativeLayout) mDrawerFragmentLayout.findViewById(R.id.header_layout);
    TextView  user_name   = (TextView)  mDrawerFragmentLayout.findViewById(R.id.header_user_name);
    TextView  user_id     = (TextView)  mDrawerFragmentLayout.findViewById(R.id.header_user_id);

    user_name.setText(localContact.getName());
    user_id.setText(localContact.getUid());
    ColorGenerator generator = ColorGenerator.DEFAULT;
    header.setBackgroundDrawable(
            builder.build(localContact.getName().substring(0, 1),
                    generator.getColor(localContact.getUid())));

    /* set the navigation menu */
    Resources res = getActivity().getResources();
    mFirstListView   = (ListView) mDrawerFragmentLayout.findViewById(R.id.navigation_first_item_list);
    firstList = new LinkedList<IconTextItem>();
    firstList.add(new IconTextItem(R.drawable.ic_group_white_24dp, res.getString(R.string.navigation_drawer_group), 1));
    firstList.add(new IconTextItem(R.drawable.ic_person_white_24dp, res.getString(R.string.navigation_drawer_contacts), 2));
    firstList.add(new IconTextItem(R.drawable.ic_hashtag, res.getString(R.string.navigation_drawer_hashtag), 3));
    firstList.add(new IconTextItem(R.drawable.ic_settings_applications_white_24dp, res.getString(R.string.navigation_drawer_settings), 4));
    firstList.add(new IconTextItem(R.drawable.ic_close_white_24dp, res.getString(R.string.navigation_drawer_exit), 5));

    mFirstListAdapter = new IconTextListAdapter(getActivity(), firstList);
    mFirstListView.setAdapter(mFirstListAdapter);
    mFirstListView.setOnItemClickListener(this);

    return mDrawerFragmentLayout;
}
 
Example 12
Source File: WeiboSdkBrowser.java    From letv with Apache License 2.0 5 votes vote down vote up
private View initTitleBar() {
    RelativeLayout titleBar = new RelativeLayout(this);
    titleBar.setLayoutParams(new LayoutParams(-1, ResourceManager.dp2px(this, 45)));
    titleBar.setBackgroundDrawable(ResourceManager.getNinePatchDrawable(this, "weibosdk_navigationbar_background.9.png"));
    this.mLeftBtn = new TextView(this);
    this.mLeftBtn.setClickable(true);
    this.mLeftBtn.setTextSize(2, 17.0f);
    this.mLeftBtn.setTextColor(ResourceManager.createColorStateList(-32256, 1728020992));
    this.mLeftBtn.setText(ResourceManager.getString(this, CANCEL_EN, "关闭", "关闭"));
    RelativeLayout.LayoutParams leftBtnLp = new RelativeLayout.LayoutParams(-2, -2);
    leftBtnLp.addRule(5);
    leftBtnLp.addRule(15);
    leftBtnLp.leftMargin = ResourceManager.dp2px(this, 10);
    leftBtnLp.rightMargin = ResourceManager.dp2px(this, 10);
    this.mLeftBtn.setLayoutParams(leftBtnLp);
    titleBar.addView(this.mLeftBtn);
    this.mTitleText = new TextView(this);
    this.mTitleText.setTextSize(2, 18.0f);
    this.mTitleText.setTextColor(-11382190);
    this.mTitleText.setEllipsize(TruncateAt.END);
    this.mTitleText.setSingleLine(true);
    this.mTitleText.setGravity(17);
    this.mTitleText.setMaxWidth(ResourceManager.dp2px(this, 160));
    RelativeLayout.LayoutParams titleTextLy = new RelativeLayout.LayoutParams(-2, -2);
    titleTextLy.addRule(13);
    this.mTitleText.setLayoutParams(titleTextLy);
    titleBar.addView(this.mTitleText);
    return titleBar;
}
 
Example 13
Source File: PasswordEditText.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
public PasswordEditText(Context context, AttributeSet attrs) {
	super(context, attrs);

	// 方式1获取属性
	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.PasswordEditText);

	hintString = a
			.getString(R.styleable.PasswordEditText_PasswordEditText_hint);

	passwordEditTextToggle = a
			.getDrawable(R.styleable.PasswordEditText_PasswordEditText_toggle);

	hintColor = a.getColor(R.styleable.PasswordEditText_PasswordEditText_hint_color,getContext().getResources().getColor(R.color.gray_half_5));

	passwordEditTextIcon = a
			.getDrawable(R.styleable.PasswordEditText_PasswordEditText_icon);


	passwordEditTextBackground = a
			.getDrawable(R.styleable.PasswordEditText_PasswordEditText_background);

	a.recycle();

	View view = LayoutInflater.from(context).inflate(
			R.layout.password_edittext, null);

	tbPasswordEditTextToggle = (ToggleButton) view
			.findViewById(R.id.tb_password_eidttext_toggle);

	if (passwordEditTextToggle != null)
		tbPasswordEditTextToggle
				.setBackgroundDrawable(passwordEditTextToggle);

	et = (EditText) view.findViewById(R.id.et_password_eidttext_edittext);
	if (!TextUtils.isEmpty(hintString))
		et.setHint(hintString);

	et.setHintTextColor(hintColor);


	rl = (RelativeLayout) view
			.findViewById(R.id.rl);
	if(passwordEditTextBackground !=null)
		rl.setBackgroundDrawable(passwordEditTextBackground);

	ivPasswordEditTextIcon = (ImageView) view.findViewById(R.id.iv_with_del_eidttext_icon);
	if (passwordEditTextIcon != null)
		ivPasswordEditTextIcon
				.setImageDrawable(passwordEditTextIcon);




	tbPasswordEditTextToggle.setChecked(true);

	tbPasswordEditTextToggle
			.setOnCheckedChangeListener(new OnCheckedChangeListener() {

				@Override
				public void onCheckedChanged(CompoundButton buttonView,
						boolean isChecked) {

					if (!isChecked) {
						et.setTransformationMethod(HideReturnsTransformationMethod
								.getInstance());
					} else {
						et.setTransformationMethod(PasswordTransformationMethod
								.getInstance());
					}
					et.postInvalidate();

					Editable editable = et.getText();
					et.setSelection(editable.length());
				}
			});

	// ivPasswordEditTextToggle.setOnClickListener(new OnClickListener() {
	// @Override
	// public void onClick(View v) {
	//
	// if (tbPasswordEditTextToggle.isChecked()) {
	// et.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
	// } else {
	// et.setInputType(InputType.TYPE_TEXT_VARIATION_NORMAL);
	// }
	// }
	// });
	// 给编辑框添加文本改变事件
	// et.addTextChangedListener(new MyTextWatcher());

	// 把获得的view加载到这个控件中
	addView(view);
}
 
Example 14
Source File: WithDelEditText.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
public WithDelEditText(Context context, AttributeSet attrs) {
        super(context, attrs);

        // 方式1获取属性
        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.WithDelEditText);


        hintString = a
                .getString(R.styleable.WithDelEditText_WithDelEditText_hint);

        hintColor = a.getColor(R.styleable.WithDelEditText_WithDelEditText_hint_color, getContext().getResources().getColor(R.color.gray_half_5));

        WithDelEditTextIcon = a
                .getDrawable(R.styleable.WithDelEditText_WithDelEditText_icon);

        WithDelEditTextDeleteIcon = a
                .getDrawable(R.styleable.WithDelEditText_WithDelEditText_delete_icon);


        WithDelEditTextDeleteIcon = a
                .getDrawable(R.styleable.WithDelEditText_WithDelEditText_delete_icon);

        WithDelEditTextBackground = a
                .getDrawable(R.styleable.WithDelEditText_WithDelEditText_background);

        lines = a.getInteger(R.styleable.WithDelEditText_WithDelEditText_lines, 1);
        maxLines = a.getInteger(R.styleable.WithDelEditText_WithDelEditText_maxLines, 1);


        a.recycle();

        View view = LayoutInflater.from(context).inflate(
                R.layout.with_del_edittext, null);

        ivWithDelEditTextDeleteIcon = (ImageView) view
                .findViewById(R.id.iv_with_del_eidttext_delete);
        if (WithDelEditTextDeleteIcon != null)
            ivWithDelEditTextDeleteIcon
                    .setImageDrawable(WithDelEditTextDeleteIcon);

        rl = (RelativeLayout) view
                .findViewById(R.id.rl);
        if (WithDelEditTextBackground != null)
            rl.setBackgroundDrawable(WithDelEditTextBackground);

        et = (EditText) view.findViewById(R.id.et_with_del_edittext);
        if (!TextUtils.isEmpty(hintString))
            et.setHint(hintString);

        et.setHintTextColor(hintColor);

        ivWithDelEditTextIcon = (ImageView) view.findViewById(R.id.iv_with_del_eidttext_icon);
        if (WithDelEditTextIcon != null) {
            ivWithDelEditTextIcon
                    .setImageDrawable(WithDelEditTextIcon);
            ivWithDelEditTextIcon.setVisibility(VISIBLE);
        }

        ivWithDelEditTextDeleteIcon.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                et.setText("");
            }
        });

        et.setLines(lines);
        et.setMaxLines(maxLines);

        // 给编辑框添加文本改变事件
        et.addTextChangedListener(new MyTextWatcher());
        et.setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View arg0, boolean arg1) {
                // TODO Auto-generated method stub
//				Log.v("Steel", "arg1:"+arg1+";"+et.hasFocus());
                if (et.hasFocus()) {
                    if (focusCheckListenter != null) {
                        focusCheckListenter.setOnFocusValue(true);
                    }
                } else {
                    if (focusCheckListenter != null) {
                        focusCheckListenter.setOnFocusValue(false);
                    }
                }
            }
        });


        // 把获得的view加载到这个控件中
        addView(view);
    }
 
Example 15
Source File: SplashActivity.java    From SweetMusicPlayer with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_splash);

    rr_splash_container = (RelativeLayout) findViewById(R.id.rr_splash_container);
    gtp_appname = (GradientTextProgress) findViewById(R.id.gtp_appname);

    int resID = R.drawable.img_splash0;
    switch (new Random().nextInt(6)) {
        case 0:
            resID = R.drawable.img_splash0;
            break;
        case 1:
            resID = R.drawable.img_splash1;
            break;
        case 2:
            resID = R.drawable.img_splash2;
            break;
        case 3:
            resID = R.drawable.img_splash3;
            break;
        case 4:
            resID = R.drawable.img_splash4;
            break;
        case 5:
            resID = R.drawable.img_splash5;
            break;
        case 6:
            resID = R.drawable.img_splash6;
            break;
        case 7:
            resID = R.drawable.img_splash7;
            break;
        case 8:
            resID = R.drawable.img_splash8;
            break;
        case 9:
            resID = R.drawable.img_splash9;
            break;
    }
    rr_splash_container.setBackgroundDrawable(getResources().getDrawable(resID));
    gtp_appname.setMaxValue(maxValue);
    gtp_appname.setProColorInt(getResources().getColor(R.color.primary));

    FileUtil.createDir(LrcUtil.lrcRootPath);

    int hasRunCount = Environment.getHasRunCount(mContext);
    if (hasRunCount == 0) {
        startActivity(SongScanActivity.Companion.getStartActIntent(mContext, true));
        finish();
    } else {
        handler.sendEmptyMessage(0);
    }
    Environment.setHasRunCount(mContext, hasRunCount + 1);
}
 
Example 16
Source File: XBanner.java    From XBanner with Apache License 2.0 4 votes vote down vote up
private void initView() {

        /*设置指示器背景容器*/
        RelativeLayout pointContainerRl = new RelativeLayout(getContext());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
        } else {
            pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
        }

        /*设置内边距*/
        pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomPading, mPointContainerLeftRightPadding, mPointTopBottomPading);

        /*设定指示器容器布局及位置*/
        mPointContainerLp = new LayoutParams(RMP, RWC);
        mPointContainerLp.addRule(mPointContainerPosition);
        if (mIsClipChildrenMode) {
            mPointContainerLp.setMargins(mClipChildrenLeftRightMargin, 0, mClipChildrenLeftRightMargin, mClipChildrenTopBottomMargin);
        }
        addView(pointContainerRl, mPointContainerLp);
        mPointRealContainerLp = new LayoutParams(RWC, RWC);
        /*设置指示器容器*/
        if (mIsNumberIndicator) {
            mNumberIndicatorTv = new TextView(getContext());
            mNumberIndicatorTv.setId(R.id.xbanner_pointId);
            mNumberIndicatorTv.setGravity(Gravity.CENTER);
            mNumberIndicatorTv.setSingleLine(true);
            mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
            mNumberIndicatorTv.setTextColor(mTipTextColor);
            mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
            mNumberIndicatorTv.setVisibility(View.INVISIBLE);
            if (mNumberIndicatorBackground != null) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
                } else {
                    mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
                }
            }
            pointContainerRl.addView(mNumberIndicatorTv, mPointRealContainerLp);
        } else {
            mPointRealContainerLl = new LinearLayout(getContext());
            mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
            mPointRealContainerLl.setId(R.id.xbanner_pointId);
            pointContainerRl.addView(mPointRealContainerLl, mPointRealContainerLp);
        }

        /*设置指示器是否可见*/
        if (mPointRealContainerLl != null) {
            if (mPointsIsVisible) {
                mPointRealContainerLl.setVisibility(View.VISIBLE);
            } else {
                mPointRealContainerLl.setVisibility(View.GONE);
            }
        }

        /*设置提示语*/
        LayoutParams pointLp = new LayoutParams(RMP, RWC);
        pointLp.addRule(CENTER_VERTICAL);

        if (mIsShowTips) {
            mTipTv = new TextView(getContext());
            mTipTv.setGravity(Gravity.CENTER_VERTICAL);
            mTipTv.setSingleLine(true);
            if (mIsTipsMarquee) {
                mTipTv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                mTipTv.setMarqueeRepeatLimit(3);
                mTipTv.setSelected(true);
            } else {
                mTipTv.setEllipsize(TextUtils.TruncateAt.END);
            }
            mTipTv.setTextColor(mTipTextColor);
            mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
            pointContainerRl.addView(mTipTv, pointLp);
        }

        /*设置指示器布局位置*/
        if (CENTER == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
            pointLp.addRule(RelativeLayout.LEFT_OF, R.id.xbanner_pointId);
        } else if (LEFT == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            if (mTipTv != null) {
                mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
            }
            pointLp.addRule(RelativeLayout.RIGHT_OF, R.id.xbanner_pointId);
        } else if (RIGHT == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            pointLp.addRule(RelativeLayout.LEFT_OF, R.id.xbanner_pointId);
        }
        setBannerPlaceholderDrawable();
    }
 
Example 17
Source File: CTInAppBaseFullHtmlFragment.java    From clevertap-android-sdk with MIT License 4 votes vote down vote up
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
private View displayHTMLView(LayoutInflater inflater, ViewGroup container) {
    View inAppView;
    try {
        inAppView = inflater.inflate(R.layout.inapp_html_full, container, false);
        RelativeLayout rl = inAppView.findViewById(R.id.inapp_html_full_relative_layout);
        RelativeLayout.LayoutParams webViewLp = new RelativeLayout
                .LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        webViewLp.addRule(RelativeLayout.CENTER_IN_PARENT);

        initWebViewLayoutParams(webViewLp);
        webView = new CTInAppWebView(getActivity().getBaseContext(), inAppNotification.getWidth(), inAppNotification.getHeight(), inAppNotification.getWidthPercentage(), inAppNotification.getHeightPercentage());
        InAppWebViewClient webViewClient = new InAppWebViewClient();
        webView.setWebViewClient(webViewClient);

        if (inAppNotification.isJsEnabled()) {
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
            webView.getSettings().setAllowContentAccess(false);
            webView.getSettings().setAllowFileAccess(false);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                webView.getSettings().setAllowFileAccessFromFileURLs(false);
            }
            webView.addJavascriptInterface(new CTWebInterface(CleverTapAPI.instanceWithConfig(getActivity(), config)), "CleverTap");
        }

        if (isDarkenEnabled())
            rl.setBackgroundDrawable(new ColorDrawable(0xBB000000));
        else
            rl.setBackgroundDrawable(new ColorDrawable(0x00000000));

        rl.addView(webView, webViewLp);

        if (isCloseButtonEnabled()) {
            closeImageView = new CloseImageView(getActivity().getBaseContext());
            RelativeLayout.LayoutParams closeIvLp = getLayoutParamsForCloseButton();

            closeImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    didDismiss(null);
                }
            });
            rl.addView(closeImageView, closeIvLp);
        }

    } catch (Throwable t) {
        config.getLogger().verbose(config.getAccountId(), "Fragment view not created", t);
        return null;
    }
    return inAppView;
}
 
Example 18
Source File: BGABanner.java    From KUtils-master with Apache License 2.0 4 votes vote down vote up
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(CENTER_VERTICAL);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);
        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
Example 19
Source File: BGABanner.java    From KUtils with Apache License 2.0 4 votes vote down vote up
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(CENTER_VERTICAL);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);
        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
Example 20
Source File: BGABanner.java    From JD-Test with Apache License 2.0 4 votes vote down vote up
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);


        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}