gpt4 book ai didi

android - 这个标签和它的子标签可以被一个 和一个复合绘图替换

转载 作者:行者123 更新时间:2023-11-29 21:51:01 25 4
gpt4 key购买 nike

我查看了类似的问题并使用了它的答案,但是如果我将它们组合成 1 个 TextView 并放置 android:drawableTop= 它在我那里显示得很奇怪现在有了它,它只是将图像堆叠在我想要的文本之上。

原创

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Navigation" >

<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/logo_name"
android:src="@drawable/generic_logo" />

<TextView
android:id="@+id/about"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about"
android:textSize="55sp"
android:onClick="onClick"
android:clickable="true" />

</LinearLayout>

与化合物

    <TextView
android:id="@+id/about"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about"
android:textSize="55sp"
android:onClick="onClick"
android:clickable="true"
android:drawableTop="@drawable/generic_logo" />

</LinearLayout>

Compound 拉伸(stretch)图像超出了我模拟的 android 的参数。我该如何解决这个问题并消除警告?

最佳答案

因此,就测量和布局而言,这两者实际上在做完全不同的事情。首先是计算图像需要多少空间,将其放在那里,计算文本需要多少空间,并将其放在图像下方。

第二个是确定文本需要多少空间。然后在背景的顶部绘制图像,缩放它以适应文本使用的整个空间。然后它在上面绘制文本。

如果您不想拉伸(stretch)图像,请使用第一个版本。第二个版本是错误的。复合可绘制对象用于 9 个补丁,其中单个背景图像被分解成多个部分。

如果这些都不是您真正想要的,请解释那是什么,我们将看看我们是否可以弄清楚如何去做。

关于android - 这个标签和它的子标签可以被一个 <TextView/> 和一个复合绘图替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14421689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com