Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中对齐并隔开3幅图像,全幅拍摄_Android_Android Layout - Fatal编程技术网

在android中对齐并隔开3幅图像,全幅拍摄

在android中对齐并隔开3幅图像,全幅拍摄,android,android-layout,Android,Android Layout,我有3张图片,我想实现我的梦想 它应该占据整个屏幕的宽度,100dp的高度(或者我会选择的任何东西) 我的照片是方形的,很大。我希望他们有一个100dp的高度,保持他们的长宽比(正方形),并间隔相等 我从这段代码中得到的是3幅图像,它们占据了1/3的宽度,不是正方形,中间没有空格 我尝试过各种方法(玩scaleType,…),但我被卡住了(除了手动将每种方法的宽度设置为100dp,这在概念上我不喜欢) 我会用代码: int resx = getWindowManager().getDefaul

我有3张图片,我想实现我的梦想

它应该占据整个屏幕的宽度,100dp的高度(或者我会选择的任何东西)

我的照片是方形的,很大。我希望他们有一个100dp的高度,保持他们的长宽比(正方形),并间隔相等

我从这段代码中得到的是3幅图像,它们占据了1/3的宽度,不是正方形,中间没有空格

我尝试过各种方法(玩
scaleType
,…),但我被卡住了(除了手动将每种方法的宽度设置为100dp,这在概念上我不喜欢)


我会用代码:

int resx = getWindowManager().getDefaultDisplay().getWidth();
int spaceBetweenPics = (resx - 300) / 2; // Two spaces taking resolution - 3 images size
Bitmap [] pics = New Bitmap[3];

for (int i = 0; i < 3; i++)  {
    pics[i] = BitmapFactory.decodeResource(getResources(), R.drawable.img1 + i); 
    // With their names, they are contiguous in the drawables index
    pics[i] = Bitmap.createScaledBitmap(pics[i], 100, 100, false);
}
int resx=getWindowManager().getDefaultDisplay().getWidth();
int spaceBetweenPics=(resx-300)/2;//两个空间的分辨率-3个图像大小
位图[]pics=新位图[3];
对于(int i=0;i<3;i++){
pics[i]=BitmapFactory.decodeResource(getResources(),R.drawable.img1+i);
//它们的名称在drawables索引中是连续的
pics[i]=Bitmap.createScaledBitmap(pics[i],100100,false);
}
在onDraw方法中:

for (int i = 0; i < 3; i++)
    canvas.drawBitmap(pics[i], (100 * i + spaceBetweenPics * i), 0, null);
for(int i=0;i<3;i++)
canvas.drawBitmap(pics[i],(100*i+spaceBetweenPics*i),0,null);
for (int i = 0; i < 3; i++)
    canvas.drawBitmap(pics[i], (100 * i + spaceBetweenPics * i), 0, null);