如何改变周围HelloGallery图像边框厚度 [英] How to change border thickness around images in HelloGallery

查看:113
本文介绍了如何改变周围HelloGallery图像边框厚度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的不知道,如果它的边框的厚度,或者需要改变图像周围的空白。我从来没有与风格的工作之前,只是创造了第一次styles.xml和colors.xml文件。我已经改变了背景颜色为红色,使用下面的image_border.xml的code。但我不知道如何改变HelloGallery在图像周围的边框厚度。

也许它不是在这个文件中。但究竟需要的东西在code写入?

 <?XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <项目的android:顶部=1DP机器人:左=1DP
        机器人:右=1DP机器人:底部=1DP>
        <形状机器人:形状=矩形>
            [固体机器人:色=@色/红/>
        < /形状>
    < /项目>
< /层列表>

编辑:答案实际上可能修改code的这一部分的问题,因为我是能够改变边界的颜色的和形象在这里的大小

 公共查看getView(INT位置,查看convertView,
      父母的ViewGroup){
        ImageView的I =新ImageView的(mContext);        位图BM = BitmapFactory.de codeFILE(
        FileList.get(位置)的ToString());
        i.setImageBitmap(BM);
        i.setLayoutParams(新Gallery.LayoutParams(160,180));
        i.setScaleType(ImageView.ScaleType.FIT_XY);
        i.setBackgroundResource(mGalleryItemBackground);
        i.setBackgroundColor(Color.BLUE);
        返回我;
    }


解决方案

图像周围的边框其实是背景​​填充:

i.setPadding(1,1,1,1);

I'm not really sure if it's the thickness of the border or the margin around the image that needs to be changed. I have never worked with styles before, and just created a styles.xml and colors.xml file for the first time. I have changed the background color to Red, using the code below in image_border.xml. But I do not know how to change the border thickness around the images in HelloGallery.

Perhaps it's not in this file. But what exactly needs to be written in the code?

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:top="1dp" android:left="1dp" 
        android:right="1dp" android:bottom="1dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/red" />
        </shape>
    </item>
</layer-list>

Edit: The answer might actually be a matter of modifying this portion of the code, since I was able to change the border color and image size here:

    public View getView(int position, View convertView,
      ViewGroup parent) {
        ImageView i = new ImageView(mContext);

        Bitmap bm = BitmapFactory.decodeFile(
        FileList.get(position).toString());
        i.setImageBitmap(bm);
        i.setLayoutParams(new Gallery.LayoutParams(160, 180));
        i.setScaleType(ImageView.ScaleType.FIT_XY);
        i.setBackgroundResource(mGalleryItemBackground);
        i.setBackgroundColor(Color.BLUE);
        return i;
    }

解决方案

The border around the image actually is background padding:

i.setPadding(1, 1, 1, 1);

这篇关于如何改变周围HelloGallery图像边框厚度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆