gpt4 book ai didi

android - 拉伸(stretch)图片的一部分,而不是整个(9patch)

转载 作者:行者123 更新时间:2023-11-29 00:23:11 29 4
gpt4 key购买 nike

问题来了: irregular size of the pictures making it ugly

如您所见,黑色的时间线被弄乱了,或多或少被拉长了。

我实际上尝试了 9patching,但老实说我没有完全理解。

真的可以解决我的问题吗?如果是,9patching 图片可以完成这项工作吗?如果是,怎么办?

另外,我给你每行的 xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<TextView
android:id="@+id/date"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="30dp"
android:textSize="20sp" />

<ImageView
android:id="@+id/point"
android:layout_width="40dp"
android:layout_height="match_parent"
android:scaleType="fitXY" />

<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textSize="20sp" />

</LinearLayout>

测试 1:

enter image description here

测试 2:

用这张照片:

enter image description here

我得到这个结果: enter image description here

测试 3: enter image description here

最佳答案

  1. 是的,使用 9 补丁是可能的。

  2. 您的 9 补丁文件有误。您已经反转了可拉伸(stretch)区域,这意味着此时圆将被拉伸(stretch),而不是其他部分。

    只需在您希望拉伸(stretch)图像的位置绘制垂直边框,在您的例子中就是圆圈下方和上方的区域。

    同时删除水平线,因为我猜您不希望拉伸(stretch)图像的宽度。

您可能会找到 this有趣的文档页面。

编辑:我只是快速尝试了我所解释的内容,并且它使用这个 9 补丁工作:

enter image description here

请注意圆圈不是 100% 居中,但它应该指向正确的方向。

关于android - 拉伸(stretch)图片的一部分,而不是整个(9patch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21647653/

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