本文整理汇总了Java中android.widget.ScrollView.getWindowVisibleDisplayFrame方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollView.getWindowVisibleDisplayFrame方法的具体用法?Java ScrollView.getWindowVisibleDisplayFrame怎么用?Java ScrollView.getWindowVisibleDisplayFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ScrollView
的用法示例。
在下文中一共展示了ScrollView.getWindowVisibleDisplayFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLayout
import android.widget.ScrollView; //导入方法依赖的package包/类
private void createLayout(int width) {
float scale = IceScreenUtils.densityScale(getApplicationContext());
int margin = 16 * Math.round(scale);
LinearLayout.LayoutParams baseParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams containerParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);
ScrollView baseScroller = new ScrollView(this);
baseScroller.setLayoutParams(baseParams);
baseScroller.setBackgroundColor(0xffffffff);
setContentView(baseScroller);
baseScroller.setVisibility(View.VISIBLE);
// display width hack
Rect windowRect = new Rect();
baseScroller.getWindowVisibleDisplayFrame(windowRect);
int windowWidth = windowRect.right - windowRect.left;
LinearLayout baseLayout = new LinearLayout(this);
baseLayout.setOrientation(LinearLayout.VERTICAL);
baseLayout.setLayoutParams(layoutParams);
baseLayout.setPadding(margin, margin, 0, 0);
baseScroller.addView(baseLayout);
String[] wallpapers = getResources().getStringArray(R.array.wallpapers);
for (int i = 0; i < wallpapers.length; i++) {
if ((i % width) == 0) {
layoutList.add((i / width), new LinearLayout(this));
layoutList.get(i / width).setOrientation(LinearLayout.HORIZONTAL);
layoutList.get(i / width).setGravity(Gravity.LEFT);
layoutList.get(i / width).setLayoutParams(containerParams);
baseLayout.addView(layoutList.get(i / width));
}
imageList.add(i, new ImageView(this));
imageList.get(i).setLayoutParams(imageParams);
imageList.get(i).setScaleType(ImageView.ScaleType.FIT_XY);
imageList.get(i).setPadding(0, 0, margin, margin);
IceImageUtils.bitmapLoadAsync(imageList.get(i), getApplicationContext(), getApplicationContext().getResources(), wallpapers[i], (windowWidth / width) - (margin * width + margin) / width, (windowWidth / width) - (margin * width + margin) / width);
imageList.get(i).setAdjustViewBounds(true);
final Integer tempId = getResources().getIdentifier(wallpapers[i], "drawable", getPackageName());
imageList.get(i).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
wallpaperView(tempId);
}
});
layoutList.get(i / width).addView(imageList.get(i));
}
}
示例2: createLayout
import android.widget.ScrollView; //导入方法依赖的package包/类
private void createLayout(int width) {
float scale = IceScreenUtils.densityScale(getApplicationContext());
int margin = 16 * Math.round(scale);
LinearLayout.LayoutParams baseParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams containerParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);
ScrollView baseScroller = new ScrollView(this);
baseScroller.setLayoutParams(baseParams);
baseScroller.setBackgroundColor(0xff000000);
setContentView(baseScroller);
baseScroller.setVisibility(View.VISIBLE);
// display width hack
Rect windowRect = new Rect();
baseScroller.getWindowVisibleDisplayFrame(windowRect);
int windowWidth = windowRect.right - windowRect.left;
LinearLayout baseLayout = new LinearLayout(this);
baseLayout.setOrientation(LinearLayout.VERTICAL);
baseLayout.setLayoutParams(layoutParams);
baseLayout.setPadding(margin, margin, 0, 0);
baseScroller.addView(baseLayout);
String[] images = getResources().getStringArray(R.array.icon_pack);
for (int i = 0; i < images.length; i++) {
if ((i % width) == 0) {
layoutList.add((i / width), new LinearLayout(this));
layoutList.get(i / width).setOrientation(LinearLayout.HORIZONTAL);
layoutList.get(i / width).setGravity(Gravity.LEFT);
layoutList.get(i / width).setLayoutParams(containerParams);
baseLayout.addView(layoutList.get(i / width));
}
imageList.add(i, new ImageView(this));
imageList.get(i).setLayoutParams(imageParams);
imageList.get(i).setScaleType(ImageView.ScaleType.FIT_XY);
imageList.get(i).setPadding(0, 0, margin, margin);
IceImageUtils.bitmapLoadAsync(imageList.get(i), getApplicationContext(), getApplicationContext().getResources(), "nodpi_" + images[i], (windowWidth / width) - (margin * width + margin) / width, (windowWidth / width) - (margin * width + margin) / width);
imageList.get(i).setAdjustViewBounds(true);
layoutList.get(i / width).addView(imageList.get(i));
}
}