本文整理汇总了Java中android.support.design.widget.CoordinatorLayout.addView方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinatorLayout.addView方法的具体用法?Java CoordinatorLayout.addView怎么用?Java CoordinatorLayout.addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.CoordinatorLayout
的用法示例。
在下文中一共展示了CoordinatorLayout.addView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAppbarEvent
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
private void setAppbarEvent() {
AppBarLayout appBar = (AppBarLayout) getParent();
if (appBar.getParent().getClass().equals(CoordinatorLayout.class)) {
CoordinatorLayout rootLayout = (CoordinatorLayout) appBar.getParent();
View tabs = getChildAt(0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
tabs.setElevation(getResources().getDimensionPixelOffset(R.dimen.tabs_elevation));
}
removeView(tabs);
rootLayout.addView(tabs);
getLayoutParams().height = getResources().getDimensionPixelOffset(R.dimen.fancy_tab_layout_height);
requestLayout();
isFloating = true;
}
appBar.addOnOffsetChangedListener(onOffsetChangedListener);
}
示例2: initContentView
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
/**
* 最外面套一层 {@link CoordinatorLayout} 是为了 解锁 {@link android.support.design.widget.Snackbar} 更多姿势,例如 滑动删除
* <p>
* {@link StatusLayout} : 多种状态下的rootView
* <p>
* 这里取巧了一下,因为 {@link org.jsoup.Jsoup} 抓取的数据都可以用一个 {@link android.support.v7.widget.RecyclerView} 来显示
* <p>
* {@link StatusLayout} SuccessView 并没有隐藏或者显示,
* 因为{@link FrameLayout} 填充 View 的时候是依次重叠的,这个时候只要最先填充 SuccessView
* 只要去控制 errorView 或者 EmptyView 隐藏或者显示就行了,会自行覆盖掉 SuccessView,真正的项目中不应该这样做,因为要处理的布局远远比这个复杂
*
* @return activity 根布局
*/
private View initContentView() {
CoordinatorLayout coordinatorLayout = new CoordinatorLayout(this);
coordinatorLayout.setId(R.id.activityRootView);
mStatusView = new StatusLayout(this);
mStatusView.setSuccessView(getLayoutId(), new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mStatusView.setEmptyView(R.layout.layout_empty_view);
mStatusView.setErrorView(R.layout.layout_network_error);
mStatusView.getEmptyView().setOnClickListener(v -> clickNetWork());
mStatusView.getErrorView().setOnClickListener(v -> clickNetWork());
setStatusViewStatus(StatusLayout.SUCCESS);
coordinatorLayout.addView(mStatusView, new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
return coordinatorLayout;
}
示例3: delegation
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
public static KeyboardInputDelegation delegation(Context context, CoordinatorLayout mCoorLayout, View mScrollerView) {
KeyboardInputDelegation delegator = new KeyboardInputDelegation(context);
View view = LayoutInflater.from(context).inflate(R.layout.view_input_wrap, mCoorLayout, false);
delegator.setWrapperView(view);
delegator.setCoorLayout(mCoorLayout);
delegator.setScrollerView(mScrollerView);
mCoorLayout.addView(view);
return delegator;
}
示例4: onAttachedToWindow
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
LayoutParams layoutParams =
new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset);
if (fabGravity == BOTTOM_END || fabGravity == TOP_END) {
layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0);
} else {
layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0);
}
menuItemsLayout.setLayoutParams(layoutParams);
// Needed in order to intercept key events
setFocusableInTouchMode(true);
if (useTouchGuard) {
ViewParent parent = getParent();
touchGuard = new View(getContext());
touchGuard.setOnClickListener(this);
touchGuard.setWillNotDraw(true);
touchGuard.setVisibility(GONE);
if (touchGuardDrawable != null) {
touchGuard.setBackground(touchGuardDrawable);
}
if (parent instanceof FrameLayout) {
FrameLayout frameLayout = (FrameLayout) parent;
frameLayout.addView(touchGuard, frameLayout.indexOfChild(this));
} else if (parent instanceof CoordinatorLayout) {
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
coordinatorLayout.addView(touchGuard, coordinatorLayout.indexOfChild(this));
} else if (parent instanceof RelativeLayout) {
((RelativeLayout) parent).addView(
touchGuard, ((RelativeLayout) parent).indexOfChild(this),
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
} else {
Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout");
}
}
setOnClickListener(this);
}
示例5: onAttachedToWindow
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
LayoutParams layoutParams =
new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset);
if (fabGravity == BOTTOM_END || fabGravity == TOP_END) {
layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0);
} else {
layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0);
}
menuItemsLayout.setLayoutParams(layoutParams);
// Set up the client's FAB
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setImageDrawable(fabDrawable);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fab.setImageTintList(fabDrawableTint);
}
if (fabBackgroundTint != null) {
fab.setBackgroundTintList(fabBackgroundTint);
}
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isAnimating) return;
if (isMenuOpen()) {
closeMenu();
} else {
openMenu();
}
}
});
// Needed in order to intercept key events
setFocusableInTouchMode(true);
if (useTouchGuard) {
ViewParent parent = getParent();
touchGuard = new View(getContext());
touchGuard.setOnClickListener(this);
touchGuard.setWillNotDraw(true);
touchGuard.setVisibility(GONE);
if (touchGuardDrawable != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
touchGuard.setBackground(touchGuardDrawable);
} else {
touchGuard.setBackgroundDrawable(touchGuardDrawable);
}
}
if (parent instanceof FrameLayout) {
FrameLayout frameLayout = (FrameLayout) parent;
frameLayout.addView(touchGuard);
bringToFront();
} else if (parent instanceof CoordinatorLayout) {
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
coordinatorLayout.addView(touchGuard);
bringToFront();
} else if (parent instanceof RelativeLayout) {
RelativeLayout relativeLayout = (RelativeLayout) parent;
relativeLayout.addView(touchGuard,
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
bringToFront();
} else {
Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout");
}
}
setOnClickListener(this);
if (shouldOpenMenu)
openMenu();
}