设置图像视图绝对位置 [英] Setting image view absolute position
问题描述
我无法访问任何适配器,这在Facebook SDK中,任何人都可以发现以下代码的任何问题:
我的XML:
DisplayPhotos.xml
<?xml version =1.0encoding =utf-8?>
< RelativeLayout xmlns:android =http://schemas.android.com/apk/res/android
android:id =@ + id / DisplayPhotosLayout
android:layout_width =match_parent
android:layout_height =match_parent>
< / RelativeLayout>
这是由以下设置:
fbManager = new FBLoginManager(this,R.layout.displayphotos,-------,permissions);
然后我使用以下内容显示图像(工作但都位于相同的位置)
int Row = 0;
int RowCount = 0;
int imageWidth =(int)getWindowManager()。getDefaultDisplay()。getWidth()/ 3;
for(int _i = 0; _i< _noOfPhotos; _i ++)
{
ImageView imageView = new ImageView(getApplicationContext());
imageView.setImageResource(R.drawable.no_image);
RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(imageWidth,imageWidth);
rl.setMargins(imageWidth * _i,imageWidth * Row,0,0);
RowCount = RowCount + 1;
if(RowCount == 3){Row = Row + 1; RowCount = 0;}
UrlImageViewHelper.setUrlDrawable(imageView,_userGallery.get(_i).getPicture ));
addContentView(imageView,rl);
System.out.println(imageWidth * _i +top:+ imageWidth * Row);
_imageViewArray.add(imageView);
}
我想你需要一张桌子布局, http://developer.android.com/guide/topics/ui /layout/grid.html
I'm trying to manually set the image-view position within my app, the code is currently working but all the facebook images display at the top right and side on top of each other.
I do not have access to any adaptors, this is within the Facebook SDK, can anyone spot any problems with the following code:
My XML:
DisplayPhotos.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/DisplayPhotosLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
This is set by the following:
fbManager = new FBLoginManager(this, R.layout.displayphotos, "-------", permissions);
Then I use the following to display images (working but all in same position)
int Row = 0;
int RowCount = 0;
int imageWidth = (int)getWindowManager().getDefaultDisplay().getWidth() / 3;
for(int _i = 0; _i < _noOfPhotos; _i++)
{
ImageView imageView = new ImageView(getApplicationContext());
imageView.setImageResource(R.drawable.no_image);
RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(imageWidth, imageWidth);
rl.setMargins(imageWidth * _i, imageWidth * Row, 0,0);
RowCount = RowCount + 1;
if(RowCount == 3){Row = Row + 1;RowCount = 0;}
UrlImageViewHelper.setUrlDrawable(imageView, _userGallery.get(_i).getPicture());
addContentView(imageView, rl);
System.out.println(imageWidth * _i + " top: " + imageWidth * Row);
_imageViewArray.add(imageView);
}
I think you need a table layout, http://developer.android.com/guide/topics/ui/layout/grid.html
这篇关于设置图像视图绝对位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!