android图片设置边框
用典型shape来当背景,linearlayout套住imageview,本来用的padding,结果导致长宽padding的距离不一样,非常难看,原来直接用margin就可以了。
<LinearLayoutandroid:id="@+id/linear_studentphoto"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/shape_photo_bg" ><ImageViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_margin="10dp"android:scaleType="centerCrop"android:src="@mipmap/baobao"android:id="@+id/student_photo" /></LinearLayout>
shape里面的代码很简单,drawable里面建一个shape_photo_bg.xml,
<?xml version="1.0" encoding="utf-8"?><shape android:shape="rectangle"xmlns:android="http://schemas.android.com/apk/res/android"><strokeandroid:color="@color/huang"android:width="15dp"/><corners android:radius="10dp"/><solid android:color="@color/huang"/>
</shape>
代码里面引用图片直接设置 外层linearlayout的布局参数就可以了,imageview只需要设置内容即可。
student_photo = (ImageView) view.findViewById(R.id.student_photo);
linear_studentphoto = (LinearLayout) view.findViewById(R.id.linear_studentphoto);
int photokuan = 70;
int photogao = 100;
linear_studentphoto.setLayoutParams(new LinearLayout.LayoutParams(photokuan, photogao));
android图片设置边框相关推荐
- android给图片加边框,android 图片加边框 ImageView border 成效
android 图片加边框 ImageView border 效果 1.布局文件 res/layout/some_page.xml android:id="@+id/respImageBor ...
- Android EditText设置边框
Android EditText设置边框 简介 Android应用程序中给EditText设置边框. 效果图: 快速开始 在res/drawable目录下新建样式文件 edit_background. ...
- border属性 php,如何通过CSS的border属性为图片设置边框效果
如何为通过css为图片设置一个边框呢,HTML中是通过标记的border属性值,给图片添加边框的,css中是通过border属性,为图片设置各式各样的边框样式,border-style定义边框的样式, ...
- Android 图片设置坐标点
plugins {id 'com.android.application'id 'kotlin-android'id 'kotlin-android-extensions'//添加扩展 } class ...
- Android ImageView设置边框
ImageView设置边框其实很简单,一个shape就能搞定,无需自定义image view. shape_gray_square_bg.xml <?xml version="1.0& ...
- Android 图片加边框
// 自定义ImageView import android.content.Context; import android.graphics.Canvas; import android.graph ...
- android imageview设置边框,android ImageView 添加边框
有两种方法可以给ImageView添加边框,一种是通过xml文件配置shape.另一种是重写ImageView的ondraw方法,这里用第二中方法: package org.example.image ...
- Android 图片设置为灰色
1.图片设置为灰色 source:图片路经源 dest:图片目的地 public static void toGrayImage(String source, String dest) { ...
- Android 按钮设置边框实例
以下一Button标签为例: 这里就联系到标签<shape>,设置背景样式.边框.渐变.圆角等,各种效果的使用方法见如下代码 drawable文件夹新建一个nimei.xml,内容如下: ...
最新文章
- 【算法】论平衡二叉树(AVL)的正确种植方法
- SQL Server2000 “mcc 无法创建管理单元”
- python中代码段的标志是什么车_请问这段Python代码是什么意思?
- php curl登陆邮箱,php利用CURL函数登入163邮箱并获取自己的通讯录
- Fragment懒加载(三)
- bzoj 1056 1862: [Zjoi2006]GameZ游戏排名系统(Treap+Hash)
- MySQL replication illegal mix of collations
- java字段映射成其他字段名称_java字段与数据库字段映射
- cubemx6.0配置touchgfx 正点原子触摸屏,touchgfx添加触摸驱动
- kindle索引_Kindle太费电?卡索引解决办法
- stm32f103zet6定时器和pwm简单驱动步进电机
- 详析百度“原创保护”使用规范,及如何推送原创文章链接?
- Fullpage.js version 3 has changed its license to GPLv3 and it requires a `licenseKey` option ...
- 【Leetcode_SQL】1179.重新格式化部门表
- Python数据分析之pandas统计分析
- python划分有限元网格_有限元网格划分和细化
- postgresql应用开发者指南
- shell-脚本集合
- 随机分组工具(工具)
- leetcode 转载