android - imageView 属性 android:adjustViewBounds=true 是否具有与 layout_width=true 和 layout_height=true 完全相同的影响?
问题描述
我正在研究ImageView小部件,看来我这两个属性(android:adjustViewBounds,layout_width和layout_height一起)对我得到的结果有相同的影响。我在问,因为也许我正在使用不适合强调差异的图像。第一个 xml 代码(android:adjustViewBounds设置为 true,layout_widht和layout_height也设置为 wrap_content,因为我必须给它们一个值):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"><TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textSize="24sp"
android:text="TextView" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:adjustViewBounds="true"
android:src="@drawable/image_1" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="TextView" />
第二个 xml 代码(相同的代码只是没有android:adjustViewBounds=true行):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textSize="24sp"
android:text="TextView" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/image_1" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="TextView" />
</LinearLayout>
解决方案
推荐阅读
- android - 如何查看 Firebase 电子商务事件的“items”参数的内容
- c# - 如何使用 C# 将 0.1333333333333333333333333333 舍入为 0.133334
- javascript - 天数 JS 挑战问题的结果?
- java - 使用 oauth2 和 Google/Azure 身份验证服务器在 Java 应用程序中注销的问题
- r - 如何在 R 中找到两个连续变量之间有意义的边界
- json - 如果父级满足条件,则删除不同的嵌套对象
- php - php中的{...}是什么意思
- r - 当外部程序通过 R 的 C API 接口调用“Rf_allocXXX”时,谁在管理内存?
- sql - 显示产品名称,所有仓库的平均数量,以及每个产品数量最多的仓库名称
- flutter - Flutter 小部件不是彼此重叠,而是彼此相邻