• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android: Frame Layout - ImageView height won't fit

Prosko

Lurker
I have a Frame Layout with an ImageView and a TextView inside it. I plan to make that text in the center of the picture. The problem is that the image won't fit, the ImageView won't wrap the height of the content good. Look at the picture:
https://i.stack.imgur.com/Urxkm.png
I need it to look like this: https://i.stack.imgur.com/UbGWJ.png

I tried mixing the height and with (wrap content and match parent) but the picture still won't fit well. This is the xml:
Code:
<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            card_view:srcCompat="@drawable/tvrdjava"
            android:id="@+id/imageView3" />

        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/textView6"
            android:textAlignment="center"
            android:textColor="@android:color/white"
            />
</FrameLayout>

I have tried android:background="@drawable/tvrdjava in a linear layout, but that stretches the image for some reason.
The picture is in different drawable folders for different resolutions (hdpi, mdpi, xhdpi, xxhdpi, xxxhdpi).

Can anybody help ?
 
I kind of fixed my own problem. I just tried it again, and for some reason it worked. Here is the xml:
Sidenote: This frame layout is in a LinearLayout (vertical).
Code:
 <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:srcCompat="@drawable/tvrdjava"
                android:id="@+id/imageView8"
                android:adjustViewBounds="true"
                android:cropToPadding="false" />

            <TextView
                android:text="TrTemp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/textView3"
                android:textColor="@color/cardview_light_background" />

        </FrameLayout>
 
Back
Top Bottom