本文整理汇总了Java中android.view.ViewGroup.addView方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.addView方法的具体用法?Java ViewGroup.addView怎么用?Java ViewGroup.addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.addView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startFullScreen
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void startFullScreen() {
if (mVideoController == null) return;
Activity activity = WindowUtil.scanForActivity(mVideoController.getContext());
if (activity == null) return;
if (isFullScreen) return;
WindowUtil.hideSystemBar(getContext());
this.removeView(playerContainer);
ViewGroup contentView = activity
.findViewById(android.R.id.content);
LayoutParams params = new LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
contentView.addView(playerContainer, params);
orientationEventListener.enable();
isFullScreen = true;
mVideoController.setPlayerState(PLAYER_FULL_SCREEN);
}
示例2: setColorForDrawerLayoutDiff
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
* @param color 状态栏颜色值
*/
@Deprecated
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 生成一个状态栏大小的矩形
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) {
contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
} else {
// 添加 statusBarView 到布局中
StatusBarView statusBarView = createStatusBarView(activity, color);
contentLayout.addView(statusBarView, 0);
}
// 内容布局不是 LinearLayout 时,设置padding top
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
}
// 设置属性
ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
drawerLayout.setFitsSystemWindows(false);
contentLayout.setFitsSystemWindows(false);
contentLayout.setClipToPadding(true);
drawer.setFitsSystemWindows(false);
}
}
示例3: 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);
}
示例4: setColorForDrawerLayoutDiff
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
* @param color 状态栏颜色值
*/
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 生成一个状态栏大小的矩形
View statusBarView = createStatusBarView(activity, color);
// 添加 statusBarView 到布局中
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
contentLayout.addView(statusBarView, 0);
// 内容布局不是 LinearLayout 时,设置padding top
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
}
// 设置属性
ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
drawerLayout.setFitsSystemWindows(false);
contentLayout.setFitsSystemWindows(false);
contentLayout.setClipToPadding(true);
drawer.setFitsSystemWindows(false);
}
}
示例5: instantiateItem
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, final int position) {
final ImageView imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
//RequestQueueHelper.getInstance(context).getImageLoader().displayImage(data.get(position), imageView);
UIUtils.setImageFromLink(imageView, data.get(position));
// if (URLUtil.isHttpsUrl(data.get(position))) {
//
// } else {
// final Bitmap bitmap = FileUtils.loadFileFromExternalStorage(context, data.get(position));
// if (bitmap != null) {
// imageView.setImageBitmap(bitmap);
// }
// }
container.addView(imageView, 0);
return imageView;
}
示例6: instantiateItem
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
// TODO Auto-generated method stub
View view = null;
view= inflater.inflate(R.layout.main_viewpager_popular, null);
ImageView img= (ImageView)view.findViewById(R.id.img_viewpager_childimage);
TextView maintext = (TextView)view.findViewById(R.id.text_viewpager_main);
TextView subtext = (TextView)view.findViewById(R.id.text_viewpager_sub);
Log.d("position", position+"");
maintext.setText(mDataset.get(position).getTitle());
subtext.setText(mDataset.get(position).getEng_title());
Log.d("image url", mDataset.get(position).getImage());
if(mDataset.get(position).getImage() == "NoImage"){
Glide.with(mContext).load(R.drawable.noimage).into(img);
} else {
String imgUrl = mDataset.get(position).getImage().substring(1, mDataset.get(position).getImage().length() - 1);
Log.d("image url2", imgUrl);
Glide.with(mContext).load(imgUrl).into(img);
}
container.addView(view);
return view;
}
示例7: instantiateItem
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ImageView instantiateItem(ViewGroup container, int position) {
ImageView imageView = (ImageView) View.inflate(mContext,R.layout.view_image, null);
if(mDatas!=null) {
MediaInfo mediaInfo = mDatas.get(position);
String assetpath = mediaInfo.getAssetpath();
if(new File(assetpath).exists()) {
Glide.with(mContext).load(mediaInfo.getAssetpath()).
placeholder(R.drawable.kong_mrjz).
dontAnimate().
into(imageView);
}else {
Glide.with(mContext).load(R.drawable.icon_pic_unexits).
placeholder(R.drawable.icon_pic_unexits).
dontAnimate().
into(imageView);
}
}
container.addView(imageView, 0);
return imageView;
}
示例8: startWindowFullscreen
import android.view.ViewGroup; //导入方法依赖的package包/类
public void startWindowFullscreen() {
Log.i(TAG, "startWindowFullscreen " + " [" + this.hashCode() + "] ");
hideSupportActionBar(getContext());
JCUtils.getAppCompActivity(getContext()).setRequestedOrientation(FULLSCREEN_ORIENTATION);
ViewGroup vp = (ViewGroup) (JCUtils.scanForActivity(getContext()))//.getWindow().getDecorView();
.findViewById(Window.ID_ANDROID_CONTENT);
View old = vp.findViewById(FULLSCREEN_ID);
if (old != null) {
vp.removeView(old);
}
// ((ViewGroup)JCMediaManager.textureView.getParent()).removeView(JCMediaManager.textureView);
textureViewContainer.removeView(JCMediaManager.textureView);
try {
Constructor<JCVideoPlayer> constructor = (Constructor<JCVideoPlayer>) JCVideoPlayer.this.getClass().getConstructor(Context.class);
JCVideoPlayer jcVideoPlayer = constructor.newInstance(getContext());
jcVideoPlayer.setId(FULLSCREEN_ID);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
vp.addView(jcVideoPlayer, lp);
jcVideoPlayer.setUp(url, JCVideoPlayerStandard.SCREEN_WINDOW_FULLSCREEN, objects);
jcVideoPlayer.setUiWitStateAndScreen(currentState);
jcVideoPlayer.addTextureView();
JCVideoPlayerManager.setSecondFloor(jcVideoPlayer);
// final Animation ra = AnimationUtils.loadAnimation(getContext(), R.anim.start_fullscreen);
// jcVideoPlayer.setAnimation(ra);
CLICK_QUIT_FULLSCREEN_TIME = System.currentTimeMillis();
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: setupStatusBarView
import android.view.ViewGroup; //导入方法依赖的package包/类
private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
mStatusBarTintView = new View(context);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
params.gravity = Gravity.TOP;
if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
params.rightMargin = mConfig.getNavigationBarWidth();
}
mStatusBarTintView.setLayoutParams(params);
mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
mStatusBarTintView.setVisibility(View.GONE);
decorViewGroup.addView(mStatusBarTintView);
}
示例10: onCreateContent
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected void onCreateContent(QMUIDialog dialog, ViewGroup parent) {
if (mMessage != null && mMessage.length() != 0) {
mTextView.setText(mMessage);
mTextView.setPadding(
QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_padding_horizontal),
QMUIResHelper.getAttrDimen(mContext, hasTitle() ? R.attr.qmui_dialog_content_padding_top : R.attr.qmui_dialog_content_padding_top_when_no_title),
QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_padding_horizontal),
QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_padding_bottom)
);
parent.addView(mTextView);
}
}
示例11: setColorDiff
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 设置状态栏颜色(5.0以下无半透明效果,不建议使用)
*
* @param activity 需要设置的 activity
* @param color 状态栏颜色值
*/
public static void setColorDiff(Activity activity, int color) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 生成一个状态栏大小的矩形
View statusView = createStatusBarView(activity, color);
// 添加 statusView 到布局中
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
decorView.addView(statusView);
setRootView(activity);
}
示例12: instantiateItem
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = mInflater.inflate(R.layout.disc_pager_item, container,false);
ImageView imageView = (ImageView) view.findViewById(R.id.iv_album);
if (position>=0 && position<playlist.size()) {
ImageCacheManager2.getInstance(container.getContext()).displayImage(imageView,playlist.get(position).getPath());
}
container.addView(view);
return view;
}
示例13: addStatusBarBehind
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 添加了一个状态栏(实际上是个view),放在了状态栏的垂直下方
*/
public static void addStatusBarBehind(Activity activity, @ColorInt int color, int statusBarAlpha) {
//获取windowphone下的decorView
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
int count = decorView.getChildCount();
//判断是否已经添加了statusBarView
if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
decorView.getChildAt(count - 1).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
} else {
//新建一个和状态栏高宽的view
StatusBarView statusView = createStatusBarView(activity, color, statusBarAlpha);
decorView.addView(statusView);
}
setRootView(activity);
}
示例14: instantiateItem
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
try {
container.addView(mListViews.get(position), 0);// 添加页卡
return mListViews.get(position);
} catch (Exception e) {
logger.e(e.getMessage());
return null;
}
}
示例15: instantiateItem
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
if (views.size() > 0) {
//position % view.size()是指虚拟的position会在[0,view.size())之间循环
View view = views.get(position % views.size());
if (container.equals(view.getParent())) {
container.removeView(view);
}
container.addView(view);
return view;
}
return null;
}