在使用imageview控件时,由于图片大小不一致,需要给图片设置个最大宽高。设置后的代码如下
但是单用
android:maxHeight="100dp"
android:maxWidth="100dp"
是不够的
文档上
An optional argument to supply a maximum width for this view. Only valid if setAdjustViewBounds(boolean)
has
been set to true.
需要
android:adjustViewBounds="true"
<ImageView
android:id="@+id/odpic"
android:layout_margin="5dp"
android:layout_toRightOf="@+id/pic"
android:maxHeight="100dp"
android:maxWidth="100dp"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY" />
同时
不可单设background 不设src 那样也会被撑开
有src 后再设background就没事
分享到:
相关推荐
ImageView 图片显示样式的几种类型。android:scaleType是控制图片如何resized/moved来匹对ImageView的size。
android:layout_width="fill_parent" android:layout_height="fill_parent" zhy:position="left_top" zhy:radius="130dp" > android:layout_width="wrap_content" android:layout_height="wrap_content" ...
xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:layout_width="fill_parent" android:layout_height="46.0dip" android:layout_marginBottom="-1.0dip" android:...
Android 开发 (实验五) 实验题目:Android 组件布局试验 指导老师: 班 级:计算机科学与技术系班 姓 名: 一、实验目的 1、掌握 Android 组件布局的使用方法 2、学会组件布局的重要属性与应用 3、能够根据需求,...
android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView ...
xmlns:android="http://schemas.android.com/apk/res/android" > <ImageView android:id="@+id/ImageView1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> android:id="@+id/...
android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView ...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" ...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="5...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" ...
代码中的例子如下: 代码如下:<ImageView android:id=”@+id/iv_bit_1″ android:layout_width=”@dimen/passcode_width” android:layout_height=”@dimen/passcode_height” android:scaleType=”fitXY”> <...
这篇随笔将会简单的记录下ImageView这个控件的一些使用方法,以及其最重要的一个属性: scaleType ImageView这个控件是用来显示图片用的,例如我们可以通过下面这段xml配置来声明显示一张图片: <ImageView n...
利用布局安排各种控件,设计良好用户界面 "<LinearLayout " "xmlns:android="schemas.android./apk/res/android" " "android:orientation="vertical" " "android:layout_width="fill_parent" " "android:layout_...
ImageView中XML属性src和background的区别: background会根据ImageView组件给定的长宽进行拉伸,而src就存放的是原图的大小,不会进行拉伸。src是图片内容(前景),bg是背景,可以同时使用。 此外:scaleType只对...
一个可配置的迷你版轻量级 Label 辅助类,支持多种配置效果。 使用样例: <cn.label.avatarlabelview.LabelImageView app:textContent="晚场" ... android:layout_width="150dp" android:layout_height="100dp"/>
<RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=match_parent android:clipChildren=false> <ImageView android:...
Android实验指导 实验一:系统安装与HelloWorld 【目的】 安装智能手机开发相关软件平台。 【要求】 1. 完成智能手机开发平台安装、以及... 利用布局安排各种控件,设计良好用户界面 "<LinearLayout " "xmlns:android=...
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="20dp" android:layout_gravity="center" android:src="@mipmap/sweet" discrollve:discrollve_scaleX=...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F0EFF5" > android:id=...
Parallax Everywhere 扩展了ImageView和TextView,使其具有视差效果。项目地址:https://github.com/Narfss/ParallaxEverywhere 效果图:如何使用:<FrameLayout android:layout_width="0dp" android:...