本文整理匯總了Java中android.view.ViewGroup.getPaddingTop方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewGroup.getPaddingTop方法的具體用法?Java ViewGroup.getPaddingTop怎麽用?Java ViewGroup.getPaddingTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.getPaddingTop方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ViewHolder
import android.view.ViewGroup; //導入方法依賴的package包/類
public ViewHolder(View itemView) {
super(itemView);
if (itemView instanceof CanMergeView) {
mCanMergeView = (CanMergeView) itemView;
} else if (itemView instanceof ViewGroup) {
ViewGroup group = (ViewGroup) itemView;
paddingLeft = group.getPaddingLeft();
paddingRight = group.getPaddingRight();
paddingTop = group.getPaddingTop();
paddingBottom = group.getPaddingBottom();
//隻遍曆一層 尋找第一個符合條件的view
for (int i = 0; i < group.getChildCount(); i++) {
View child = group.getChildAt(i);
if (child instanceof CanMergeView) {
mCanMergeView = (CanMergeView) child;
break;
}
}
}
}
示例2: invalidateDividersForScrollingView
import android.view.ViewGroup; //導入方法依賴的package包/類
private void invalidateDividersForScrollingView(ViewGroup view, final boolean setForTop, boolean setForBottom, boolean hasButtons) {
if (setForTop && view.getChildCount() > 0) {
drawTopDivider = titleBar != null &&
titleBar.getVisibility() != View.GONE &&
//Not scrolled to the top.
view.getScrollY() + view.getPaddingTop() > view.getChildAt(0).getTop();
}
if (setForBottom && view.getChildCount() > 0) {
drawBottomDivider = hasButtons &&
view.getScrollY() + view.getHeight() - view.getPaddingBottom() < view.getChildAt(view.getChildCount() - 1).getBottom();
}
}
示例3: setColorForSwipeBack
import android.view.ViewGroup; //導入方法依賴的package包/類
/**
* 為滑動返回界麵設置狀態欄顏色
*
* @param activity 需要設置的activity
* @param color 狀態欄顏色值
* @param statusBarAlpha 狀態欄透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例4: setColorForSwipeBack
import android.view.ViewGroup; //導入方法依賴的package包/類
/**
* 為滑動返回界麵設置狀態欄顏色
*
* @param activity 需要設置的activity
* @param color 狀態欄顏色值
* @param statusBarAlpha 狀態欄透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例5: 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]);
}
示例6: setColorForSwipeBack
import android.view.ViewGroup; //導入方法依賴的package包/類
/**
* 為滑動返回界麵設置狀態欄顏色
*
* @param activity 需要設置的activity
* @param color 狀態欄顏色值
* @param statusBarAlpha 狀態欄透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例7: setColorForSwipeBack
import android.view.ViewGroup; //導入方法依賴的package包/類
/**
* 為滑動返回界麵設置狀態欄顏色
*
* @param activity 需要設置的activity
* @param color 狀態欄顏色值
* @param statusBarAlpha 狀態欄透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例8: setColorForSwipeBack
import android.view.ViewGroup; //導入方法依賴的package包/類
/**
* 為滑動返回界麵設置狀態欄顏色
*
* @param activity 需要設置的activity
* @param color 狀態欄顏色值
* @param statusBarAlpha 狀態欄透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例9: BaseHolder
import android.view.ViewGroup; //導入方法依賴的package包/類
public BaseHolder(LayoutInflater inflater, ViewGroup parent, @LayoutRes int layoutId, boolean isFillParent) {
super(inflate(inflater, parent, layoutId));
if (isFillParent && parent != null) {
getItemView().getLayoutParams().height = parent.getMeasuredHeight() - (parent.getPaddingTop() + parent.getPaddingBottom());
}
}