0

アップデート

次のスタイルを追加してアプリケーションに設定すると、画面全体が描画されます。

<resources>
    <style name="app_theme" parent="android:Theme.NoTitleBar">
        <item name="android:windowBackground">@color/green</item>
    </style>    
</resources> 

私の最初のAndroidアプリを開発しているときに、ダウンロードした他のサンプルプロジェクトとは異なり、アプリのビューが画面全体に広がることはないことに気付きました。これをテストするために、基本的なアクティビティクラスを作成し、背景TextViewを緑に設定して、それがどの程度広がっているかを確認しました。これがばかげた質問なら許してください、しかし私はこれに不慣れです。

スクリーンショットは次のとおりです。

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

完全なHomeActivityソースは次のとおりです。

public class HomeActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

レイアウトファイル(/res/layout/main.xml)は次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:text="Hello World, StackOverflow"
    android:background="#00FF00"
    />
</LinearLayout>

これは、ウィンドウ全体にまたがって正常に動作しているエミュレーターの別のアプリのスクリーンショットです。

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

編集

XMLファイルを次のように編集しました。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#00FF00"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:text="Hello World, StackOverflow"
    />
</LinearLayout>

次に、クリーニングして構築し、実行して、まったく同じビューを取得しました。

編集2

要求に応じて「垂直」方向線を削除しましたが、変更はありません。

これが私のAndroidManifestです:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.blah.blah.myCrap"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    <application android:label="@string/app_name" >
        <activity android:name="HomeActivity"
                  android:label="@string/app_name">
        <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest> 

以下を私のマニフェストに追加しました<application>

<supports-screens android:resizeable="true"
                      android:smallScreens="true" 
                      android:normalScreens="true" 
                      android:largeScreens="true"

                      android:anyDensity="true" />

それでも間違ったサイズ。

4

2 に答える 2

1

Android2.2エミュレーターで問題なく動作します

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

于 2012-05-11T18:31:54.063 に答える
1

マニフェストをチェックして、さまざまな画面サイズをサポートしているかどうかを確認してください。このQAで詳細情報を見つけることができます(fill_parentはLinearLayoutの画面全体を埋めていません

明らかに、小さい、通常、大きい、任意の密度の画面サイズをサポートするように指定しないと、レイアウトが画面全体に表示されないという問題が発生する可能性があります。

于 2012-05-11T18:38:56.790 に答える