本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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]);
}
示例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;
}
示例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);
}
示例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);
}