android – 将ImageView缩放为XML格式的TextView

android – 将ImageView缩放为XML格式的TextView,第1张

概述我有一个水平线性布局的TextView和 ImageView.是否可以缩放ImageView以使其相对于布局文件中TextView的大小? 基本上我想要的东西: – 而不是像这样的东西 布局文件将是 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" a 我有一个水平线性布局的TextVIEw和 ImageVIEw.是否可以缩放ImageVIEw以使其相对于布局文件中TextVIEw的大小?

基本上我想要的东西: –

而不是像这样的东西

布局文件将是

<linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:orIEntation="horizontal" >    <ImageVIEw />    <TextVIEw /></linearLayout>
解决方法 是的,您可以在相对于TextVIEw的高度缩小ImageVIEw.要匹配TextVIEw的高度,请将match_parent设置为ImageVIEw的androID:layout_height,这将有助于ImageVIEw获取TextVIEw的高度.尝试如下……
<linearLayout    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:orIEntation="horizontal" >    <ImageVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="match_parent"        androID:src="@drawable/ic_launcher" />    <TextVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="TextVIEw"        androID:textSize="30sp" /></linearLayout>

您也可以通过以下方式获得相同的结果……

<TextVIEw    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:drawableleft="@drawable/ic_launcher"    androID:text="TextVIEw"    androID:gravity="center_vertical"    androID:textSize="30sp" />
总结

以上是内存溢出为你收集整理的android – 将ImageView缩放为XML格式的TextView全部内容,希望文章能够帮你解决android – 将ImageView缩放为XML格式的TextView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1130404.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存