cozmin-calin
cozmin-calin

Reputation: 421

Background image android xamarin

I tried to set a background image for the main activity in android (using xamarin). The image is shown in the design but when I emulate to my phone (Galaxy S4) is not show. Here is the code. What is wrong here ?

        <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/home"
        android:scaleType="fitXY" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:columnCount="1"
            android:layout_gravity="bottom"
            android:minHeight="250dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:minHeight="125dp">
                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Button 1"
                    android:layout_gravity="center" />
                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Button 2" />
                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:minHeight="125dp">
                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Button 3"
                    android:layout_gravity="center" />
                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Button 4" />
                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
            </LinearLayout>
        </GridLayout>
    </LinearLayout>
</RelativeLayout>

Upvotes: 0

Views: 1140

Answers (1)

iwanlenin
iwanlenin

Reputation: 222

It maybe to big. Show in console for error like this: Bitmap too large to be uploaded into a texture (4350x2448, max=4096x4096)

Try to put the image to drawable-nodpi

Android background image memory usage

Upvotes: 2

Related Questions