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

时间:2018-10-31 08:27:55

标签: android bitmap share-intent

我从同一设备获得不同的位图大小。 首先,我是根据活动创建的,另一项是根据recylerview中的项目单击创建的。

Recylerview screen from where I am creating bitmap to share

在这里,我的身高在1350左右。

下面是活动性屏幕截图。

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 下出现问题。当我不使用它时,在两种情况下我都得到相同高度的位图。

1 个答案:

答案 0 :(得分:1)

更改

android:layout_height="wrap_content"

android:layout_height="match_parent"

在您的logoLL线性布局中