本文整理汇总了Java中android.view.ViewGroup.removeViewInLayout方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.removeViewInLayout方法的具体用法?Java ViewGroup.removeViewInLayout怎么用?Java ViewGroup.removeViewInLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.removeViewInLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeView
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* remove a view
*
* @param parent
* @param view
*/
public static void removeView(ViewGroup parent, View view) {
//这里不使用post来做,这样代码更可控,而是改为将refresh下拉动作延后一帧处理,见@link
//这里调用removeViewInLayout方法,可以在onLayout的时候调用,否则会产生问题
if (parent != null && view != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (parent.isInLayout()) {
parent.removeViewInLayout(view);
} else {
parent.removeView(view);
}
} else {
parent.removeView(view);
}
}
}
示例2: mockStartWithPopAnim
import android.view.ViewGroup; //导入方法依赖的package包/类
private void mockStartWithPopAnim(ISupportFragment from, ISupportFragment to, final Animation exitAnim) {
Fragment fromF = (Fragment) from;
final ViewGroup container = findContainerById(fromF, from.getSupportDelegate().mContainerId);
if (container == null) return;
from.getSupportDelegate().mLockAnim = true;
View fromView = fromF.getView();
container.removeViewInLayout(fromView);
final ViewGroup mock = addMockView(fromView, container);
to.getSupportDelegate().mEnterAnimListener = new SupportFragmentDelegate.EnterAnimListener() {
@Override
public void onEnterAnimStart() {
mock.startAnimation(exitAnim);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
container.removeView(mock);
}
}, exitAnim.getDuration() + BUFFER_TIME);
}
};
}
示例3: inflate
import android.view.ViewGroup; //导入方法依赖的package包/类
public View inflate() {
ViewParent viewParent = getParent();
if (viewParent == null || !(viewParent instanceof ViewGroup)) {
throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");
} else if (this.mLayoutResource != 0) {
LayoutInflater factory;
ViewGroup parent = (ViewGroup) viewParent;
if (this.mInflater != null) {
factory = this.mInflater;
} else {
factory = LayoutInflater.from(getContext());
}
View view = factory.inflate(this.mLayoutResource, parent, false);
if (this.mInflatedId != -1) {
view.setId(this.mInflatedId);
}
int index = parent.indexOfChild(this);
parent.removeViewInLayout(this);
LayoutParams layoutParams = getLayoutParams();
if (layoutParams != null) {
parent.addView(view, index, layoutParams);
} else {
parent.addView(view, index);
}
this.mInflatedViewRef = new WeakReference(view);
if (this.mInflateListener != null) {
this.mInflateListener.onInflate(this, view);
}
return view;
} else {
throw new IllegalArgumentException("ViewStub must have a valid layoutResource");
}
}