---
title: "android  -> ImageButton 内部图片 padding"
author: "mft8899"
date: "2020-04-09T12:00:47Z"
tags: []
categories: ["移动开发"]
slug: "android-imagebutton-padding"
draft: false
lastmod: "2020-04-09T13:56:56Z"
id: 2513498
url: "https://mft.iteye.com/blog/2513498"
---

先给 ImageButton 设置属性 

```
android:scaleType="fitCenter"
```

 

然后 新建 drawable,   imgbtn\_pd.xml 设置 background 的pading

 

```
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
	<padding
		android:top="15dp"
		android:bottom="15dp"
	/>
	<solid android:color="#00ffffff"/><!-- 填充的颜色 -->
</shape>
```

 

 

然后将 这个background 设置到 imageButton 

```
android:background="@drawable/imgbtn_pd"
```