1

私は自分のアプリケーションの奇妙な振る舞いを実験しています。すべての透明な背景がランダムな画像に置き換えられています。これは例です(大きいサイズで申し訳ありません):

ここに画像の説明を入力してください

これは、listView(すべてのセルに透明な背景があります)を含む中央(透明な背景)にRelativeLayoutがあるアクティビティです。すべての透明な背景を置き換えるこの巨大なログアウト画像があることがわかります。この画像はまったく異なるレイアウトで使用されており、アクティビティのレイアウトのxmlファイルにはまったく表示されません。この問題は(私が知る限り)Samsung Galaxy Note(私は体と心のすべてで嫌いです)でのみ発生し、エミュレーターで動作する他のすべてのデバイスでもスムーズに機能します。私はすでにプロジェクトをクリーンアップし、アプリを再インストールし、私が知っている他のすべてのトラブルシューティングの予備的な練習をしました。

これが起こっている理由について誰かが何か考えを持っていますか?

これはxmlファイルです:

<?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"
    android:background="@drawable/io_guido_background" >

    <!-- header -->

    <RelativeLayout
        android:id="@+id/headerlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/pezzo_bar"
        android:gravity="top" >

        <ImageView
            android:id="@+id/header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:scaleType="fitStart"
            android:src="@drawable/logo_bar" />

        <TextView
            android:id="@+id/titolo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="30dp"
            android:layout_marginTop="10dp"
            android:gravity="left|top"
            android:text="Archivio"
            android:textColor="@color/white"
            android:textSize="16dp"
            android:textStyle="bold" />
    </RelativeLayout>

    <!-- body -->

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/headerlayout" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="480dp"
            android:layout_centerInParent="true"
            android:orientation="vertical" >

            <!-- box date -->

            <RelativeLayout
                android:id="@+id/sceltadate"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:background="@drawable/io_guido_rect_2" >

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dp"
                    android:background="@drawable/io_guido_periodo"
                    android:scaleType="fitStart" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="50dp"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Da: "
                        android:textColor="@color/black" />

                    <Button
                        android:id="@+id/dabtn"
                        android:layout_width="100dp"
                        android:layout_height="wrap_content"
                        android:background="@drawable/textedit_state"
                        android:onClick="setData" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="40dp"
                        android:text="A: "
                        android:textColor="@color/black" />

                    <Button
                        android:id="@+id/abtn"
                        android:layout_width="100dp"
                        android:layout_height="wrap_content"
                        android:background="@drawable/textedit_state"
                        android:onClick="setData" />
                </LinearLayout>
            </RelativeLayout>
            <!--  -->


            <!-- body lista -->

            <RelativeLayout
                android:id="@+id/body"
                android:layout_width="fill_parent"
                android:layout_height="338dp"
                android:layout_above="@+id/legenda"
                android:layout_below="@+id/sceltadate"
                android:layout_margin="10dp" >

                <RelativeLayout
                    android:id="@+id/subbody"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_above="@+id/backgroung"
                    android:background="#f3f3f3" >
                </RelativeLayout>

                <ImageView
                    android:id="@+id/backgroung"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:background="@drawable/io_guido_rect_3_new" />

                <!-- logo

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginBottom="30dp"
                    android:layout_marginRight="10dp"
                    android:scaleType="fitStart"
                    android:src="@drawable/logo_trasparente" />
                 fine logo -->


                <!-- lista -->

                <LinearLayout
                    android:id="@+id/layoutlista"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ListView
                        android:id="@id/android:list"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_marginBottom="10dp"
                        android:background="@color/transparent"
                        android:cacheColorHint="@color/transparent" >
                    </ListView>
                </LinearLayout>

                <!-- sfondoTop -->
            </RelativeLayout>

            <!-- fine bodyLista -->


            <!-- body legenda -->

            <LinearLayout
                android:id="@+id/legenda"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_alignParentBottom="true"
                android:layout_marginBottom="15dp"
                android:gravity="center_horizontal"
                android:orientation="horizontal" >

                <!-- Prenotata -->

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:paddingRight="10dp" >

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ready" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Prenotata"
                        android:textColor="@color/black" />
                </LinearLayout>

                <!-- In corsa -->

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical" >

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/pronta" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="In corsa"
                        android:textColor="@color/black" />
                </LinearLayout>

                <!-- terminata -->

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:paddingLeft="10dp" >

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ok" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Terminata"
                        android:textColor="@color/black" />
                </LinearLayout>

                <!-- Annullata -->

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:paddingLeft="10dp" >

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/x" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Annullata"
                        android:textColor="@color/black" />
                </LinearLayout>
            </LinearLayout>
            <!-- fine body legenda -->

        </RelativeLayout>
    </RelativeLayout>
    <!-- fine body -->

</RelativeLayout>
4

2 に答える 2

1

特にこの種のデバイス用に特別なレイアウトを作成してみましたか?しばらく前に私は同様の問題を抱えていましたが、このデバイスの画面仕様で新しいレイアウトを作成することで解決しました。

これが発生する理由は、デフォルトのレイアウトを作成すると、中程度の画面密度で使用するように作成されるためです。高密度の画面でアプリケーションを実行すると、Androidはレイアウトを画面のサイズと密度に合わせようとします。Androidが背景が画面密度に正しく適合しないことを理解した場合、Androidは背景を塗りつぶす他の方法を使用しようとします。サポートする密度ごとにレイアウトを作成することをお勧めします。IE、通常(mdpi)、高(hdpi)、低(ldpi)。

実行時に、システムは、特定のリソースに対して次の手順を使用して、現在の画面で可能な限り最高の表示を保証します。

リソースは、構成修飾子でタグ付けされていないリソースです。たとえば、drawable /のリソースは、デフォルトのドローアブルリソースです。システムは、デフォルトのリソースがベースラインの画面サイズと密度(通常の画面サイズと中密度)用に設計されていることを前提としています。そのため、システムは、必要に応じて、デフォルトの密度リソースを高密度画面の場合はスケールアップし、低密度画面の場合はスケールダウンします。ただし、システムが密度固有のリソースを探していて、密度固有のディレクトリでそれが見つからない場合、常にデフォルトのリソースを使用するとは限りません。代わりに、システムは、スケーリング時に優れた結果を提供するために、他の密度固有のリソースの1つを使用する場合があります。たとえば、低密度のリソースを探していて、それが利用できない場合、システムは、高密度バージョンのリソースをスケールダウンすることを好みます。これは、中密度リソースをスケーリングする場合と比較して、アーティファクトが少なく、高密度リソースを0.5倍の低密度に簡単にスケールダウンできるためです。 0.75倍。...」(developer.android.com/guide/practices/screens_support.html)

Androidがリソースを選択する方法を深く理解するには、このトピックを確認してください:Androidが最適なリソースを見つける方法

この助けを願っています。

于 2013-01-08T17:55:36.970 に答える
1

私は同じ問題を経験していました。に置き換えることで修正できましandroid:background="@color/transparent"android:background="@null"。これは、Samsungタブレットに固有のものである可能性があります(Galaxyタブで見ました)。

于 2014-01-23T15:03:43.890 に答える