图片视图、图片按钮和单选按钮

  1 <?xml version="1.0" encoding="utf-8"?>
  2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3     xmlns:tools="http://schemas.android.com/tools"
  4     android:layout_width="match_parent"
  5     android:layout_height="match_parent"
  6     android:paddingBottom="@dimen/activity_vertical_margin"
  7     android:paddingLeft="@dimen/activity_horizontal_margin"
  8     android:paddingRight="@dimen/activity_horizontal_margin"
  9     android:paddingTop="@dimen/activity_vertical_margin"
 10     tools:context="com.hanqi.testapp2.TestActivity1"
 11     android:orientation="vertical">
 12
 13     <LinearLayout
 14         android:layout_width="match_parent"
 15         android:layout_height="wrap_content">
 16     <ImageButton
 17         android:layout_width="wrap_content"
 18         android:layout_height="wrap_content"
 19         android:src="@drawable/anniu04"/>
 20     <ImageButton
 21         android:layout_width="wrap_content"
 22         android:layout_height="wrap_content"
 23         android:src="@drawable/anniu05"/>
 24     <Button
 25         android:layout_width="wrap_content"
 26         android:layout_height="wrap_content"
 27         android:background="@drawable/anniu04"
 28         android:text="普通按钮"/>
 29     </LinearLayout>
 30
 31     <LinearLayout
 32         android:layout_width="match_parent"
 33         android:layout_height="wrap_content">
 34     <ImageView
 35         android:layout_width="100dp"
 36         android:layout_height="100dp"
 37         android:src="@drawable/yuantu"
 38         android:alpha="1"
 39         android:background="#f00"
 40         android:scaleType="center"/>
 41     <ImageView
 42         android:layout_width="100dp"
 43         android:layout_height="100dp"
 44         android:src="@drawable/yuantu"
 45         android:alpha="1"
 46         android:background="#f00"
 47         android:scaleType="centerCrop"/>
 48         <ImageView
 49             android:layout_width="100dp"
 50             android:layout_height="100dp"
 51             android:src="@drawable/yuantu"
 52             android:alpha="1"
 53             android:background="#f00"
 54             android:scaleType="centerInside"/>
 55     </LinearLayout>
 56     <LinearLayout
 57         android:layout_width="match_parent"
 58         android:layout_height="wrap_content">
 59         <ImageView
 60             android:layout_width="100dp"
 61             android:layout_height="100dp"
 62             android:src="@drawable/yuantu"
 63             android:alpha="1"
 64             android:background="#f00"
 65             android:scaleType="matrix"/>
 66         <ImageView
 67             android:layout_width="100dp"
 68             android:layout_height="100dp"
 69             android:src="@drawable/yuantu"
 70             android:alpha="1"
 71             android:background="#f00"
 72             android:scaleType="fitCenter"/>
 73
 74     </LinearLayout>
 75     <LinearLayout
 76         android:layout_width="match_parent"
 77         android:layout_height="wrap_content">
 78         <ImageView
 79             android:layout_width="100dp"
 80             android:layout_height="100dp"
 81             android:src="@drawable/yuantu"
 82             android:alpha="1"
 83             android:background="#f00"
 84             android:scaleType="fitStart"/>
 85         <ImageView
 86             android:layout_width="100dp"
 87             android:layout_height="100dp"
 88             android:src="@drawable/yuantu"
 89             android:alpha="1"
 90             android:background="#f00"
 91             android:scaleType="fitEnd"/>
 92
 93         <ImageView
 94             android:layout_width="100dp"
 95             android:layout_height="100dp"
 96             android:src="@drawable/yuantu"
 97             android:alpha="1"
 98             android:background="#f00"
 99             android:scaleType="fitXY"/>
100     </LinearLayout>
101     <RadioGroup
102         android:layout_width="match_parent"
103         android:layout_height="wrap_content">
104         <RadioButton
105             android:layout_width="wrap_content"
106             android:layout_height="wrap_content"
107             android:text="男"/>
108         <RadioButton
109             android:layout_width="wrap_content"
110             android:layout_height="wrap_content"
111             android:text="女"/>
112     </RadioGroup>
113 </LinearLayout>

效果为:

另附图片视图属性:

时间: 2024-08-10 07:48:18

图片视图、图片按钮和单选按钮的相关文章

02-常见控件:ImageView(图片视图)、slider(滑动器)、switch(开关)使用

效果图:       通过点击设置 将显示如第二张图所示                            第三张为项目目录文件 供参考              主要代码: // // WHBLAPViewController.h // 04-whblap查看器 // // Created by whblap on 14-6-6. // Copyright (c) 2014年 whblap. All rights reserved. // #import <UIKit/UIKit.h>

iOS 图片视图UIImageView小记

1关于在图片视图上添加按钮后,点击按钮没反应的问题 一般情况下是由于图片视图没有开启用户交互导致的,也有可能是按钮视图被其他视图覆盖了或者超出范围 现在是开启用户交互的代码,你要手动开启,默认是关闭的 yourImageView.userInteractionEnabled = YES

Android——图片视图(ImageView)、状态开关按钮(ToggleButton)、时钟

xml <?xml version="1.0" encoding="utf-8"?> <!--滚动视图--> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_pare

IOS开发——UI进阶篇(十八)核心动画小例子,转盘(裁剪图片、自定义按钮、旋转)图片折叠、音量震动条、倒影、粒子效果

一.转盘(裁剪图片.自定义按钮.旋转) 1.裁剪图片 将一张大图片裁剪为多张 // CGImageCreateWithImageInRect:用来裁剪图片 // image:需要裁剪的图片 // rect:裁剪图片的尺寸,传递是像素 CGImageRef norImage = CGImageCreateWithImageInRect(norBigImage.CGImage, clipRect); 2.每次点击按钮立马变为选中状态,并且取消上次的按钮的选中状态 当然还要重写- (void)setH

atitit.GUI图片非规则按钮跟动态图片切换的实现模式总结java .net c# c++ web html js

atitit.GUI图片非规则按钮跟动态图片切换的实现模式总结java .net c# c++ web html js 1. 图片按钮的效果总结 1 1.1. 按钮图片自动缩放的. 1 1.2. 不要边框,如果用自定义图片做按钮背景可以设为 false. 2 1.3. 异形按钮 2 1.4. 不绘制焦点 2 1.5. 鼠标经过时的图标 2 1.6. 选中时的图标 2 1.7. 禁用时显示的图标 2 1.8. 可能需要按钮半透明效果 2 2. 图片按钮的实现 2 2.1. 优先模式:button控

154在屏幕中绘图时设置透明度(扩展知识:为图片视图添加点击手势识别器,来实现点击事件操作)

一张图片,通过混合模式绘制后,能得到不同效果的图片. 这里的示例仅是测试效果:实际上可以通过不同程度的混合模式绘制,来得到符合需求的效果. 效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @property (strong, nonatomic) UIImageView *imgVBlend; 5 @property (strong, nona

阅读《Android 从入门到精通》(20)——图片视图

图片视图(ImageView) ImageView 类属于 android.Widget 包并且继承于 android.widget.View 类,派生了 ImageButton 和 ZoomButton 等子类,主要用于对图片作相关处理.可以通过 setImageBitmap 方法或 setImageResource(int) 方法设置图片资源,或者通过 android:src 属性指定. ImageView 类方法 ImageView 示例 完整工程:http://download.csdn

UIImageView图片视图的基本概念和使用方法

IOS学习笔记(十)之UIImageView图片视图的基本概念和使用方法(博客地址: http://blog.csdn.net/developer_jiangqq ) Author:hmjiangqq Email:[email protected] UIImageView: 作用:专门用于显示图片 首先看下官方的解说: An image view object provides a view-based container for displaying either a single image

devexpress表格控件gridcontrol图片列,按钮列,时间列等特殊列的实现

1.项目中经常会在表格中插入按钮列,图片列,表格列一些非文本的特殊列.如何在devexpress表格控件gridcontrol中实现呢?以下列举一个实现添加图片列,按钮列,时间列,按钮列,开关列的示例,效果图如下: 2.数据代码,其中图片列使用了两种方法,大家可根据自己要求变跟. Image img = Image.FromFile(Application.StartupPath+"\\img\\11111.png");//方法1 //byte[] imgbyte=getImageBy