2012-05-11 13 views
0

更新Hello WorldのAndroidアクティビティが画面全体に表示されないのはなぜですか?

次のスタイルを追加し、自分のアプリケーションのためにそれを設定した後、私はそれが画面全体を描画得ている:

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

私は私のアプリのことを実現してきた私の最初のAndroidアプリを開発している間私のダウンロードした他のサンプルプロジェクトは、スクリーン全体に広がることはありません。これをテストするために、基本アクティビティクラスを作成し、TextViewの背景を緑色に設定して、どれくらいのスパンがあるかを確認しました。もしこれが愚かな質問であれば私を許してください。しかし私はこれを初めて学んでいます。ここで

はスクリーンショットです:ここでは

enter image description here

は、完全なHomeActivity源である:

<?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> 

と、ここ:ここ

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)でありますeの別のアプリのスクリーンショットですmulatorウィンドウ全体にわたる、細かい作業:

enter image description here

編集

を私は今であることを私の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" /> 

間違ったサイズの下で私のマニフェストに以下を追加しました。

+2

リニアレイアウトの背景色を設定します。これにより、切り捨てられているTextViewか、LinearLayoutかどうかを確認できます。 – Gophermofur

+0

@GophermofurはTextViewからbgを削除しました.LinearLayoutに追加され、クリーンでビルドされました。同じ結果のビュー:-(。 –

+0

manifest.xmlを投稿できますか? – Gophermofur

答えて

1

それは、Android 2.2エミュレータ

enter image description here

1

に細かい来ていますが、それは別の画面サイズをサポートしているかどうかを確認するためにあなたのマニフェストを確認してください。詳細については、このQA(fill_parent is not filling entire screen in LinearLayout

などがあります。小さい、普通、大きい、任意の大画面サイズをサポートしていると指定していない場合は、レイアウト全体で画面に表示されない問題があります。

+0

私はこの1つに大きな期待をしていましたが、動作しませんでした。 +ビルド、実行、同じ結果。 –

関連する問題