當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewGroup.setBackgroundResource方法代碼示例

本文整理匯總了Java中android.view.ViewGroup.setBackgroundResource方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewGroup.setBackgroundResource方法的具體用法?Java ViewGroup.setBackgroundResource怎麽用?Java ViewGroup.setBackgroundResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.setBackgroundResource方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: attachToActivity

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 設置關聯的 Activity
 * 重要!必須調用
 *
 * @param activity
 */
public void attachToActivity(Activity activity, @EdgeFlag int edgeFlag) {
    mAttachActivity = activity;
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{
            android.R.attr.windowBackground
    });
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    _setContentView(decorChild);
    decor.addView(this);
    setEdgeFlag(edgeFlag);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:SwipeBackLayout.java

示例2: configureCard

import android.view.ViewGroup; //導入方法依賴的package包/類
private void configureCard(ViewGroup card) {
    cardContent.setMaxWidth(getCardWidth());
    cardContent.setPadding(
            CARD_PADDING_VERTICAL,
            CARD_PADDING_HORIZONTAL,
            CARD_PADDING_VERTICAL,
            CARD_PADDING_HORIZONTAL
    );
    cardContent.setLayoutParams(new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT
    ));

    card.setBackgroundResource(getCardBackgroundDrawable());
    card.addView(cardContent);

    FrameLayout.LayoutParams cardLayoutParams = generateDefaultLayoutParams();
    cardLayoutParams.width = LayoutParams.WRAP_CONTENT;
    cardLayoutParams.height = LayoutParams.WRAP_CONTENT;
    cardLayoutParams.gravity = getCardGravity();
    cardLayoutParams.leftMargin = getCardMarginLeft();
    cardLayoutParams.topMargin = getCardMarginTop();
    cardLayoutParams.rightMargin = getCardMarginRight();
    cardLayoutParams.bottomMargin = getCardMarginBottom();
    card.setLayoutParams(cardLayoutParams);
}
 
開發者ID:dimorinny,項目名稱:show-case-card-view,代碼行數:27,代碼來源:ShowCaseView.java

示例3: attachToActivity

import android.view.ViewGroup; //導入方法依賴的package包/類
public void attachToActivity(Activity activity) {
    mActivity = activity;
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{
            android.R.attr.windowBackground
    });
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:17,代碼來源:SwipeBackLayout.java

示例4: attachToActivity

import android.view.ViewGroup; //導入方法依賴的package包/類
public void attachToActivity(FragmentActivity activity) {
    mActivity = activity;
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{
            android.R.attr.windowBackground
    });
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:17,代碼來源:SwipeBackLayout.java

示例5: attachToActivity

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 將SwipeFinishLayout關聯到指定activity中
 * @param activity
 */
public void attachToActivity(Activity activity) {
    mActivity = activity;
    TypedArray ta = activity.getTheme().obtainStyledAttributes(
            new int[] {android.R.attr.windowBackground});
    int background = ta.getResourceId(0, 0);
    ta.recycle();

    // 設置window樣式,FEATURE_NO_TITLE
    activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    // 係統內置,/platforms/android-25/data/res/layout/screen_custom_title.xml
    ViewGroup decorChild = (ViewGroup) decorView.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decorView.removeView(decorChild);
    addView(decorChild);
    // 設置content view
    mContentView = (View) decorChild.getParent();
    // 將SwipeFinishLayout添加到decorView中
    decorView.addView(this);
}
 
開發者ID:lorienzhang,項目名稱:SwipeFinishLayout,代碼行數:25,代碼來源:SwipeFinishLayout.java

示例6: setViewPadding

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 調整位置Padding
 * @param parent
 * @param background
 */
private void setViewPadding(ViewGroup parent, int background) {
    int[] rect = new int[4];
    rect[0] = parent.getPaddingLeft();
    rect[1] = parent.getPaddingTop();
    rect[2] = parent.getPaddingRight();
    rect[3] = parent.getPaddingBottom();
    parent.setBackgroundResource(background);
    parent.setPadding(rect[0], rect[1], rect[2], rect[3]);
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:15,代碼來源:OverflowAdapter.java

示例7: getSelectorDialog

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * menu action selector Dialog
 *
 * @return dialog
 */
private Dialog getSelectorDialog() {
    if (mSelectorDialog == null) {
        mSelectorDialog = new BottomDialog(this, true);
        @SuppressLint("InflateParams") View view = LayoutInflater.from(this).inflate(R.layout.view_nearby_operator, null, false);
        view.findViewById(R.id.tv_clear_opt).setOnClickListener(this);
        view.findViewById(R.id.tv_cancel_opt).setOnClickListener(this);
        mSelectorDialog.setContentView(view);
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null) {
            parent.setBackgroundResource(R.color.transparent);
        }
    }
    return mSelectorDialog;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:20,代碼來源:NearbyActivity.java

示例8: attachToActivity

import android.view.ViewGroup; //導入方法依賴的package包/類
public void attachToActivity(Activity activity) {
    mActivity = activity;
    TypedArray a = activity.getTheme().obtainStyledAttributes(
            new int[]{android.R.attr.windowBackground});
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}
 
開發者ID:haihaio,項目名稱:AmenEye,代碼行數:16,代碼來源:SwipeBackLayout.java

示例9: attachToActivity

import android.view.ViewGroup; //導入方法依賴的package包/類
public void attachToActivity(Activity activity) {
    this.mActivity = activity;
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{16842836});
    int background = a.getResourceId(0, 0);
    a.recycle();
    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:14,代碼來源:SwipeBackLayout.java


注:本文中的android.view.ViewGroup.setBackgroundResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。