アップデート
次のスタイルを追加してアプリケーションに設定すると、画面全体が描画されます。
<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" />
それでも間違ったサイズ。