0

I try to make a Layout with two TextViews on top and an ImageView on the bottom of the Layout. But I have problems with the scalingtyp of the ImageView. The Image should always resize propotional but be always on the center buttom. Here is a picture with my problem:

Layout

I hope you unterstand my problem.
Here is my code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
android:orientation="vertical" >

<TextView
    android:id="@+id/textViewGameOver1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="top|center_horizontal"
    android:gravity="center"
    android:text="TextView1"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textViewGameOver2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewGameOver1"
    android:layout_centerHorizontal="true"
    android:layout_gravity="top|center_horizontal"
    android:gravity="center"
    android:text="TextView2"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<ImageView
    android:id="@+id/imageViewGameOver"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/textViewGameOver2"
    android:layout_centerHorizontal="true"
    android:layout_gravity="bottom|center_horizontal"
    android:scaleType="fitEnd"
    android:src="@drawable/sheldon_win" />

</RelativeLayout>

Have anybody a idea to solve this problem?

Best regards!

4

1 回答 1

1

您应该使用 aRelativeLayout而不是 a LinearLayout。这将使您可以将图像放置在您想要的位置,然后您可以将图像的大小设置为ImageView您想要的任何大小。

<ImageView
    android:id="@+id/imageViewGameOver"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:src="@drawable/sheldon_win" />

这应该将图像放在右下角,并且图像应该是图像文件的大小。如果要更改它,可以将宽度和高度设置为 dp 中的某个大小。

于 2012-09-19T17:53:49.927 回答