最近在用ImageButton,发现,我如果new ImageButton,并且 设置Warp_content,但是它并不会正真的warp,它会有一个边框。

不知道怎么回事。

后来,在代码里面使用ImageButton,我发现用Inflate去加载它就没有问题,大小什么的都没有问题,上下也居中。

layout_titlebar_imagebtn.xml

<?xml version="1.0" encoding="utf-8"?>
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/titlebar_btn_width_height"
android:layout_height="@dimen/titlebar_btn_width_height"
android:background="@drawable/online_title_bar_item_bg_sel"
android:src="@drawable/online_selector_return_button"> </ImageButton>
ImageButton img = (ImageButton)mInflater.inflate(R.layout.layout_titlebar_imagebtn, null);

这样就可以了。不知道为什么会有这种问题。

ImageButton的坑 ImageButton 有问题的更多相关文章

  1. android控件---自定义带文本的ImageButton

    由于SDK提供的ImageButton只能添加图片,不能添加文字:而Button控件添加的文字只能显示在图片内部:当我们需要添加文字在图片外部时就不能满足我们的需求了,顾只能自己写个自定义ImageB ...

  2. Android 自定义Android带图片和文字的ImageButton

    经过分析,上述按钮效果实际上就是一个布局,一个最简单不过的垂直线性布局,上部分是一个ImageView,下部分是一个TextView,这个布局可点击.可设置监听. 我们首先要编写自己的ImageBut ...

  3. 带文字的ImageButton[自定义]

    今天Android项目中遇到一个ImageButton控件上面要显示文字,无奈自定义了一个ImageButton,继承自ImageButton.其实就是override这个控件的onDraw(Canv ...

  4. 【传】玩转Android---UI篇---ImageButton(带图标的按钮)

    原文网址:http://hualang.iteye.com/blog/964049 除了Android系统自带的Button按钮一万,还提供了带图标的按钮ImageButton 要制作带图标的按钮,首 ...

  5. ImageButton与Button

    1.Button控件 Butotn控件,主要用来实现一些命令操作,通过注册监听事件来实现.首先需要在xml文档中放入一个button按钮. <Button android:id="@+ ...

  6. WPF 自定义 ImageButton

    控件源码: public class ImageButton : Button    {        public ImageButton() {        } public string No ...

  7. Android 按钮 Button和ImageButton

    Button -- 按钮ImageButton -- 图片按钮Button和ImageButton特征1.共有的特征都可以作为一个按钮产生点击事件2.不同点: (1)Button有text属性,Ima ...

  8. 【Wince-自定义控件】ImageButton 带图片、文字

    1.看图 可以实现MouseDown改变背景颜色或背景图片. 遗憾是没有实现键盘触发按钮事件. 2.选择继承自Control基类 public class ImageButton : Control ...

  9. Android的界面组件使用之ImageButton和ImageView,ImageSwitcher和GridView

    (一)ImageButton和ImageView ImageButton与Button的功能完全相同,只是ImageButton上显示的是图像,并且每个ImageButton组件都必须指定一个id,以 ...

随机推荐

  1. 时域反射计(TDR)原理与应用

    [施工编辑中...] 1. 什么是TDR? TDR = Time Domain Reflectometry 时域反射计TDR用来测量信号在通过某类传输环境传导时引起的反射,如电路板轨迹.电缆.连接器等 ...

  2. System Center Configuration Manager 2016 必要条件准备篇(Part2)

    步骤2.下载并安装Windows ADK.WDS组件 注意:在Configuration Manager服务器(CM16)上以本地管理员身份执行以下操作 当我们使用Configuration Man ...

  3. An internal error occurred during: "Generating JAX-WS Web Services".Unable to create JAXBContext

    使用myeclipse10 创建webservice时,提示错误: An internal error occurred during: "Generating JAX-WS Web Ser ...

  4. replace into 浅析

    转载自:http://blog.itpub.net/22664653/viewspace-1669734/ http://blog.itpub.net/22664653/viewspace-16701 ...

  5. POJ-3009 Curling 2.0---DFS求最短路

    题目链接: https://vjudge.net/problem/POJ-3009 题目大意: 问题:打冰球.冰球可以往上下左右4个方向走,只有当冰球撞到墙时才会停下来,而墙会消失.当冰球紧贴墙时,不 ...

  6. EF问题集合

    1. 在使用数据迁移的过程中,如果手工删除了本地数据库之后,再次尝试连接被删除的数据库,会有以下提示: System.Data.SqlClient.SqlException (0x80131904): ...

  7. ceph-对象存储

    ceph对象存储 作为文件系统的磁盘,操作系统不能直接访问对象存储.相反,它只能通过应用程序级别的API访问.ceph是一种分布式对象存储系统,通过ceph对象网关提供对象存储接口,也称为RADOS网 ...

  8. 改Chrome的User Agent,移动版网络

    理论上访问手机版或者iPad等平板电脑版的网络,应该可以剩些流量的,毕竟移动网络是经过优化压缩的,但是PC电脑如果访问移动版的网站呢?我主要使用的浏览器是Chrome,这几天也找了下Chrome下的修 ...

  9. Python——配置环境的导出与导入

    导出Python环境安装包[root@bogon ~]# pip freeze > packages.txt 这将会创建一个 packages.txt文件,其中包含了当前环境中所有包及各自的版本 ...

  10. Spring整合JUnit spring静态对象属性的注入

    package cn.itcast.d_junit4; import org.junit.Test; import org.junit.runner.RunWith; import org.sprin ...