- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用下面的方法
我拥有的 TextView 中的 setCompoundDrawablesWithIntrinsicBounds(null,null,null,drawable)。可绘制对象位于文本下方,但问题是它从文本开始的地方开始。有什么方法可以设置它,使图像上方的文本水平居中?
例如,代替
Sample Text
----------------
| |
| |
----------------
让它看起来像那样
Sample Text
----------------
| |
| |
----------------
PS:我知道我可以将 Layout 与 TextView 和 ImageView 一起使用并对齐它们,但我试图只使用 TextView 但它本身来显示文本和图像
谢谢
最佳答案
试试这个,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableBottom="@drawable/ic_launcher"
android:gravity="center_horizontal"
android:text="Hello Android" />
</LinearLayout>
输出看起来像这样,
关于android - 使用 drawableBottom 时居中文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33646158/
我有几个 LinearLayouts(见底部图片和一段代码)。每个按钮上都有一个文本,文本下面有一个图像。但是有一个问题。当应用程序在分辨率较低的移动设备上运行时,图像会隐藏文本。我该如何防止这种情况
我正在使用下面的方法 我拥有的 TextView 中的 setCompoundDrawablesWithIntrinsicBounds(null,null,null,drawable)。可绘制对象位于
保存在 res/drawable/gradient_box.xml 的 XML 文件: (以上形状定义取自当时的Android开发者指南,没有错误)。 让我们尝试将
有没有办法可以将 text 属性放置在 android:drawableBottom 属性上方。这是我的尝试 这是以下代码的屏幕截图 已编辑这是线性布局,显示了按钮组如何放置在水平方向
我是一名优秀的程序员,十分优秀!