【问题标题】:Unable to display the long images without making them look "Stretched"无法显示长图像而不使它们看起来“拉伸”
【发布时间】:2017-08-21 08:58:10
【问题描述】:

请检查以下布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_view_message"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="xxx.xxx.xxx.xxx.activities.ViewMessageActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="24dp"
            android:background="@drawable/linear_border"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_marginTop="12dp"
                android:orientation="horizontal">

                <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/view_message_channel_img"
                    android:layout_width="64dp"
                    android:layout_height="64dp"
                    android:layout_marginLeft="5dp"
                    android:src="@drawable/sm_human"
                    app:civ_border_color="#FF000000"
                    app:civ_border_width="0.5dp" />

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

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/view_message_channel_name_txt"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="John Doe"
                            android:textColor="@android:color/black"
                            android:textSize="12sp" />

                        <TextView
                            android:id="@+id/view_message_duration_txt"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_weight="2"
                            android:text="3h Ago"
                            android:textAlignment="textEnd"
                            android:textSize="12sp" />

                    </LinearLayout>

                    <TextView
                        android:id="@+id/view_message_time_txt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="18dp"
                        android:text="Jan 6 at 4.55 PM"
                        android:textSize="12sp" />

                </LinearLayout>

            </LinearLayout>

            <TextView
                android:id="@+id/view_message_message_txt"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="12dp"
                android:text="Daily dose of proper pills"
                android:textColor="@android:color/black"
                android:textSize="12sp" />


            <ImageView
                android:id="@+id/view_message_image"
                android:layout_width="match_parent"
                android:layout_height="256dp"
                android:layout_marginTop="12dp"
                android:background="@android:color/darker_gray"
                />

            <!--<VideoView-->
                <!--android:id="@+id/view_message_video_view"-->
                <!--android:layout_width="match_parent"-->
                <!--android:layout_height="256dp"-->
                <!--android:layout_marginTop="12dp" />-->

            <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
                android:layout_width="match_parent"
                android:layout_height="250sp"
                android:id="@+id/video_player"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="48dp" />

        </LinearLayout>

    </ScrollView>

</LinearLayout>

我正在尝试使图像在view_message_image 中可见。这种情况是,只要有“长肖像”图像可用,它就会像下面这样被拉伸。

我尝试使用wrap_content 的高度,imageview 的高度和宽度,但这使图像完全消失,什么都看不见。

我该如何解决这个问题?

【问题讨论】:

  • 投反对票:在此处发布投反对票的原因,然后再继续。这就是 S.O 的工作原理。

标签: java android android-layout android-imageview android-image


【解决方案1】:

在您的 ImageView 中尝试此行;

android:scaleType="fitXY"

【讨论】:

  • 我做到了,但注意到变化
猜你喜欢
  • 2020-06-17
  • 1970-01-01
  • 2012-06-24
  • 2011-02-07
  • 2022-06-21
  • 1970-01-01
  • 1970-01-01
  • 2020-10-09
  • 1970-01-01
相关资源
最近更新 更多