本文整理了Java中android.widget.GridView.getVerticalSpacing()
方法的一些代码示例,展示了GridView.getVerticalSpacing()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.getVerticalSpacing()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:getVerticalSpacing
暂无
代码示例来源:origin: liaohuqiu/android-GridViewWithHeaderAndFooter
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public int getVerticalSpacing() {
int value = 0;
try {
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion < Build.VERSION_CODES.JELLY_BEAN) {
Field field = GridView.class.getDeclaredField("mVerticalSpacing");
field.setAccessible(true);
value = field.getInt(this);
} else {
value = super.getVerticalSpacing();
}
} catch (Exception ignore) {
}
return value;
}
代码示例来源:origin: square/assertj-android
@TargetApi(JELLY_BEAN)
public GridViewAssert hasVerticalSpacing(int spacing) {
isNotNull();
int actualSpacing = actual.getVerticalSpacing();
assertThat(actualSpacing) //
.overridingErrorMessage("Expected vertical spacing <%s> but was <%s>.", spacing,
actualSpacing) //
.isEqualTo(spacing);
return this;
}
代码示例来源:origin: zzkong/BaseProject
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public int getVerticalSpacing() {
int value = 0;
try {
int currentapiVersion = Build.VERSION.SDK_INT;
if (currentapiVersion < Build.VERSION_CODES.JELLY_BEAN) {
Field field = GridView.class.getDeclaredField("mVerticalSpacing");
field.setAccessible(true);
value = field.getInt(this);
} else {
value = super.getVerticalSpacing();
}
} catch (Exception ignore) {
}
return value;
}
代码示例来源:origin: navyifanr/AndroidTrainingDemo
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public int getVerticalSpacing() {
int value = 0;
try {
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion < Build.VERSION_CODES.JELLY_BEAN) {
Field field = GridView.class.getDeclaredField("mVerticalSpacing");
field.setAccessible(true);
value = field.getInt(this);
} else {
value = super.getVerticalSpacing();
}
} catch (Exception ignore) {
}
return value;
}
代码示例来源:origin: madreain/AndroidDream
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public int getVerticalSpacing() {
int value = 0;
try {
int currentapiVersion = Build.VERSION.SDK_INT;
if (currentapiVersion < Build.VERSION_CODES.JELLY_BEAN) {
Field field = GridView.class.getDeclaredField("mVerticalSpacing");
field.setAccessible(true);
value = field.getInt(this);
} else {
value = super.getVerticalSpacing();
}
} catch (Exception ignore) {
}
return value;
}
代码示例来源:origin: com.squareup.assertj/assertj-android
@TargetApi(JELLY_BEAN)
public GridViewAssert hasVerticalSpacing(int spacing) {
isNotNull();
int actualSpacing = actual.getVerticalSpacing();
assertThat(actualSpacing) //
.overridingErrorMessage("Expected vertical spacing <%s> but was <%s>.", spacing,
actualSpacing) //
.isEqualTo(spacing);
return this;
}
代码示例来源:origin: LRH1993/LiveCircle
private void setHeaderItemValues(HeaderViewHolder holder) {
NewsChannelGridAdapter mAdapter = new NewsChannelGridAdapter(mTables, context);
holder.mGridView.setAdapter(mAdapter);
//解决GridView只显示一行的原因 主动设置GridView的高度
ViewGroup.LayoutParams params = holder.mGridView.getLayoutParams();
View view = mAdapter.getView(0, null, holder.mGridView);
view.measure(0,0);
int height =view.getMeasuredHeight();
int totalHeight = holder.mGridView.getVerticalSpacing() * 2 + height * 2;
params.height = totalHeight;
holder.mGridView.setLayoutParams(params);
}
代码示例来源:origin: mouxuefei/KotlinMvpExample
/**
* 动态设置gridView的高度
*
* @param gridView
* @param columns 列数
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public static void setGridViewHeight(GridView gridView, int columns) {
ListAdapter adapter = gridView.getAdapter();
int count = adapter.getCount();
int row = count / columns;
row = (count % columns) == 0 ? row : (row + 1);
int totalHeight = 0;
for (int i = 0; i < row; i++) {
View view = adapter.getView(i, null, gridView);
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams layoutParams = gridView.getLayoutParams();
layoutParams.height = totalHeight + (gridView.getVerticalSpacing() * (row - 1));
gridView.setLayoutParams(layoutParams);
}
内容来源于网络,如有侵权,请联系作者删除!