gpt4 book ai didi

android - Android Studio 中 xml 上的图像在高度方向上异常拉伸(stretch)

转载 作者:行者123 更新时间:2023-11-29 02:24:10 25 4
gpt4 key购买 nike

编辑:我的图像存在分辨率问题,分辨率越高,空白区域越多。但我无法获得正确的分辨率。如果分辨率太高,问题就在这里,如果它足以让图像适合 720p 显示器,那么 QHD 或更高显示器上的图像质量就会很差。除了分辨率之外,我似乎无法在互联网上找到任何其他解决方案,所以请帮忙!

我放在 XML 上的图像没有可见的 layout_marginVertical。我没有把那个属性放在那里,如果我写的话,它确实会垂直放置那个边距,从而导致困惑的情况。即使我包装了所有内容,也会发生这种情况。这是我在代码中插入的图像:

Image

这是我得到的结果:

![result

这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/backgroundcolor"
tools:context=".RegistrationActivity">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/android_course_thumbnail"
android:layout_marginBottom="20sp"/>

</androidx.cardview.widget.CardView>

</LinearLayout>

</ScrollView>

</RelativeLayout>

<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/backgroundcolor"
app:headerLayout="@layout/navigation_header"
app:menu="@menu/navigation_menu" />

</androidx.drawerlayout.widget.DrawerLayout>

最佳答案

删除 ScrollView ,并将图像调整为 480x800 分辨率

关于android - Android Studio 中 xml 上的图像在高度方向上异常拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53260696/

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