android - 从不同屏幕创建时在同一设备上获取不同的位图大小

标签 android bitmap share-intent

我从同一个设备上得到了不同大小的位图。 首先,我从 Activity 创建,另一个我从 recylerview 中的项目点击创建。

Recylerview screen from where I am creating bitmap to share

这里我的高度在 1350 左右。

下面是 Activity 屏幕截图。

Activity Screen[2]

在这里,我得到了 1425 左右高度的位图。在同一设备 moto g4 上。 我使用相同的 java 类以及相同的 xml 类。 下面是我的 xml 代码。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:id="@+id/parentLL"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/parentRL"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:orientation="vertical"
        android:padding="10dp"
       >

        <android.support.v7.widget.CardView
            android:id="@+id/cardLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            card_view:cardCornerRadius="4dp"

            card_view:cardElevation="4dp"
            card_view:cardUseCompatPadding="true">

            <FrameLayout
                android:id="@+id/imageFL"
                android:layout_width="match_parent"
                android:layout_height="300dp">

                <ImageView
                    android:id="@+id/featuredCellImageView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:src="@drawable/placeholder_default_image" />

                <RelativeLayout
                    android:layout_width="match_parent"

                    android:layout_height="match_parent"
                    android:layout_gravity="center">

                    <ImageView
                        android:id="@+id/featuredCellCentreImageView"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginLeft="2dp"
                        android:layout_marginTop="2dp"
                        android:adjustViewBounds="true"
                        android:scaleType="fitCenter"
                        android:src="@drawable/placeholder_default_image" />
                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/topBannerRL"
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    android:layout_gravity="top"
                    android:background="#90000000">

                    <ImageView
                        android:id="@+id/logoIV"
                        android:layout_width="120dp"
                        android:layout_height="40dp"
                        android:layout_margin="15dp"
                        android:src="@drawable/splash_text" />
                </RelativeLayout>
            </FrameLayout>
        </android.support.v7.widget.CardView>

        <LinearLayout
            android:id="@+id/rl_title"
            android:layout_below="@+id/cardLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="2dp"

            android:background="#ffffff"
            android:orientation="vertical">

            <TextView
                android:id="@+id/featuredCellTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:ellipsize="end"
                android:maxLines="3"
                android:padding="2dp"
                android:textColor="#000000"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/description"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="5dp"
                android:layout_marginRight="5dp"
                android:ellipsize="end"
                android:maxLines="6"
                android:textColor="#000000"
                android:textSize="14sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="visible"
                android:id="@+id/logosLL"
                android:gravity="center|right">

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:layout_marginRight="4dp"
                    android:src="@drawable/ios_app_store" />

                <ImageView
                    android:id="@+id/playIV"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="4dp"
                    android:src="@drawable/google_play" />
            </LinearLayout>
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>

logoLL linearlayout 下方创建问题。当我不使用它时,我会在两种情况下得到相同高度的位图。

最佳答案

改变

android:layout_height="wrap_content"

android:layout_height="match_parent"

在你的 logoLL 线性布局中

关于android - 从不同屏幕创建时在同一设备上获取不同的位图大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53079138/

相关文章:

android - 与文本(主题标签)共享图像作为 Android 中的 Instagram 故事

android - 通过 Whatsapp 或 Facebook 分享图片和文字

java - 分享时将标题文字加粗

Android - 在按钮内旋转图像

android - 将当前 TextView 内容绘制到 Bitmap

java - 转换 Android Base64 位图并在 HTML Base64 图像上显示

c# - 给定一个颜色对象列表,找到出现频率最高/最少的颜色,并将其作为颜色对象返回

android - Android布局中的填充颜色

android - 如何使用位置管理器但没有位置监听器获取 Android 当前位置 "only on demand"?

android - 如何更新表值