[Android]Android 布局中如何让图片和文字居中显示?
图片文字居中显示
**①组件TextView的属性 drawableTop
```
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/dp_10"
>
<TextView
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:drawableTop="@mipmap/xinyongxinxichaxun"
android:layout_weight="1"
android:text="不查征信"
android:textSize="@dimen/dp_11"
android:textColor="@color/gray9"
android:gravity="center"
/>
<TextView
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:drawableTop="@mipmap/biangengshoujihao"
android:layout_weight="1"
android:text="手机号借款"
android:textSize="@dimen/dp_11"
android:textColor="@color/gray9"
android:gravity="center"
/>
<TextView
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:drawableTop="@mipmap/vip"
android:layout_weight="1"
android:text="高通过率"
android:textSize="@dimen/dp_11"
android:textColor="@color/gray9"
android:gravity="center"
/>
<TextView
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:drawableTop="@mipmap/zhimafen"
android:layout_weight="1"
android:text="芝麻分550"
android:textSize="@dimen/dp_11"
android:textColor="@color/gray9"
android:gravity="center"
/>
<TextView
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:drawableTop="@mipmap/shinshopxinpin"
android:layout_weight="1"
android:text="今日新品"
android:textSize="@dimen/dp_11"
android:textColor="@color/gray9"
android:gravity="center"
/>
</LinearLayout>
```
显示的效果如下图所示:

[Android]Android 布局中如何让图片和文字居中显示?的更多相关文章
- android:scaleType 布局文件加载图片时候的显示方式
android:scaleType="center" 以原图的几何中心点和ImagView的几何中心点为基准,按图片的原来size居中显示,不缩放,当图片长/宽超过View的长/宽 ...
- 【css对齐】块内或者行内图片与文字居中对齐最靠谱的方式!
块内或者行内图片与文字居中对齐最靠谱的方式! 做图片与文字在一行的按钮时候最常用到,总结了一个靠谱的方法,终于可以完美的对齐下面给个代码 首先是html: <p class="btnU ...
- (Android UI)Android应用程序中资源:图片、字符串、颜色、布局等
Android系统设计采用代码和布局分离的设计模式,因此在设计Android应用程序时需要遵循该设计模式. “把非代码资源(如图片和字符串常量)和代码分离开来始终是一种很好的做法.”---<An ...
- 【Android】安卓中常用的图片加载方法
一.通过相机选图片: 布局文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...
- 从零开始学android开发-布局中 layout_gravity、gravity、orientation、layout_weight
线性布局中,有 4 个及其重要的参数,直接决定元素的布局和位置,这四个参数是 android:layout_gravity ( 是本元素相对于父元素的重力方向 ) android:gravity (是 ...
- android 在布局中动态添加控件
第一步 final LayoutInflater inflater = LayoutInflater.from(this); 第二步:获取需要被添加控件的布局 final LinearLayout l ...
- Winform DataGridView列的单元格中动态添加图片和文字
先上图在说,第二列中图片和文字的样式 1.需要重写DataGridViewTextBoxColumn,新建类TextAndImageColumn.cs using System; using Syst ...
- 在QTableWidget中添加QCheckBox并使其居中显示(转)
实现思路:把QCheckBox嵌入式到一个水平布局中 QWidget *widget; QHBoxLayout *hLayout; QCheckBox *ckb; ... ckb = ...
- 69、Android 布局中轻松实现图片的全屏、居中、平铺
public void paint() { if (item.laying_mode != 1)//平铺或者充满 { new AsyncTask<Void, Void, Void>() { ...
随机推荐
- sqrti128
求平方根下取整,对于gcc type __uint128_t. ~45.5ns/op on i7-7700k@4.35G,即typical <200cyc/op. Together with u ...
- VC++使用CImage PNG转BMP图片透明背景处理
PNG格式的图片是支持透明通道的,BMP格式的图片是没有透明通道的,所以当PNG格式的图片转换为BMP格式时,对于PNG图片的透明背景就需要进行特别的处理. VC++中的HBITMAP是支持透明色的, ...
- CSS样式实现溢出超出DIV边框宽度高度的内容自动隐藏方法
CSS样式实现溢出超出DIV边框宽度高度的内容自动隐藏方法 平时我们布局时候,有的文字内容多了会超过溢出我们限制的高度,有的图片会撑破DIV,让网页错位变乱. 这样我们就需要解决如何使用CSS来超出设 ...
- 使用Word2010发布博客文章
发布博客可以直接在web页面上面编辑,也可以使用客户端编辑,其中客户端支持windows live writer以及word本身的发布博客功能.个人试用后倾向于使用word发布博客文章. 下面的内容转 ...
- javascript学习教程
我来班门弄斧一下吧,把我JavaScript学习过程中常去的一些网站分享给大家: =========================增加================================ ...
- noip2016 普及组
T1 买铅笔 题目传送门 #include<cstdio> #include<cstring> #include<algorithm> using namespac ...
- 【BZOJ】1692: [Usaco2007 Dec]队列变换
[算法]字符串hash [题解] 显然如果字母互不相同,贪心取是正确的. 如果存在字母相同,那么就换成比较后缀和前缀嘛. 但是要注意,不是后缀和前缀相同就能直接跳跃,每次必须只推一位. 取模的哈希比自 ...
- javascript的阻塞机制
javascript的阻塞机制 浏览器在执行javascript代码时,不能同时做其它事情,当遇到javascript时,浏览器会下载js文件,解析并执行该文件,而在这期间页面的渲染是完全被阻塞的,因 ...
- [Leetcode Week2]Sort Colors
Sort Colors题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/sort-colors/description/ Description Give ...
- Raspberry Pi使用
1. 介绍 笔者Raspberry Pi 2 Model B为例介绍 1.1 参数 Raspberry Pi 2 Model B硬件参数如下: · Broadcom BCM2836 900MHz 4核 ...