0

アプリをアップグレードしてアクション バーを含めようとしていますが、書式設定について少し混乱しています。

したがって、最初のアクティビティは問題ないように見えます。コードは次のとおりです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" 
android:layout_height="match_parent">

<TextView  
    android:id="@+id/main_title"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/main_title"
    android:textSize="24sp" 
    android:textColor="@color/orange"
    android:textStyle="bold"
    android:gravity="center_vertical|center_horizontal" 
    android:padding="20dp"/>
    <Button 
    android:id="@+id/new_inspection" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/main_title"
    android:text="@string/create_new_inspection"/>
    <TextView  
    android:id="@+id/saved_inspections"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/new_inspection"
    android:text="@string/saved_inspections" 
    android:padding="5dp"/>
    <ListView 
    android:id="@id/android:list" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/saved_inspections"/>
    <TextView  
    android:id="@id/android:empty"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/no_saved_inspections"
    android:gravity="center" 
    android:padding="20dp"
    android:layout_below="@id/saved_inspections"/>
</RelativeLayout>

このための OnCreate メソッド:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_inspection);
    setUpViews();
    setLongClick();
    rmDbHelper = new RMDbAdapter(this);
    rmDbHelper.open();
    Cursor listCursor = rmDbHelper.fetchAllInspections();
    startManagingCursor(listCursor);           
    setListAdapter(new MyListAdapter(this, listCursor));  
}

次のようになります。

正しいレイアウト

しかし、他のアクティビティのいくつかはこのようには見えず、その理由はわかりません。たとえば、次のアクティビティのコードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/heading_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
    <TextView  
    android:id="@+id/main_title"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/main_title" 
    android:textSize="18sp"
    android:textStyle="bold" 
    android:textColor="@color/orange"
    android:gravity="center_vertical|center_horizontal" 
    android:padding="5dp"/>
    <TextView  
    android:id="@+id/secondary_title"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/main_title"
    android:text="@string/secondary_title"
    android:textStyle="bold" 
    android:gravity="center_vertical|center_horizontal" 
    android:padding="5dp"/>
    <Button 
    android:id="@+id/new_run" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/secondary_title"
    android:text="@string/create_new_run"/>
    <TextView  
    android:id="@+id/saved_runs"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/new_run"
    android:text="@string/saved_runs" 
    android:padding="5dp"/>
</RelativeLayout>

<LinearLayout
android:id="@+id/complete_button_layout" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
    <Button
    android:id="@+id/complete_button"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/run_area_complete"
    android:padding="5dp"/>
</LinearLayout>

<ListView 
android:id="@id/android:list" 
android:layout_width="fill_parent" 
android:layout_height="0dp"
android:layout_below="@id/heading_layout"
android:layout_above="@id/complete_button_layout"/>
<TextView  
android:id="@id/android:empty"
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/no_saved_runs"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_below="@id/heading_layout"
android:layout_above="@id/complete_button_layout"/> 

</RelativeLayout>

このためのOnCreate:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_run);
    rmDbHelper = new RMDbAdapter(this);
    rmDbHelper.open();
    Intent i = getIntent();
    inspectionId = i.getLongExtra("Intent_InspectionID", -1);
    areaId = i.getLongExtra("Intent_AreaID", -1);
    setUpViews();
    setLongClick();
    Cursor listCursor = rmDbHelper.fetchAllRunsForArea(areaId);
    startManagingCursor(listCursor);           
    setListAdapter(new MyListAdapter(this, listCursor));
}

次のようになります。

間違ったレイアウト

色はショップ全体にあり、xml ファイルの違いはわかりません..

情報のマニフェストは次のとおりです。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.scamparelli.rm"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="16" />

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

<application
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo" >
    <activity
        android:name=".InspectionActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize"
        android:label="@string/title_activity_inspection" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".InspectionEdit"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize"/>
    <activity android:name=".AreaActivity"
        android:screenOrientation="portrait"/>
    <activity android:name=".AreaEdit"
        android:screenOrientation="portrait"/>
    <activity android:name=".RunActivity"
        android:screenOrientation="portrait"/>
    <activity android:name=".RunEdit"
        android:screenOrientation="portrait"/>
    <activity android:name=".LocationActivity"
        android:screenOrientation="portrait"/>
    <activity android:name=".ComponentEdit"
        android:screenOrientation="portrait"/>
    <activity android:name=".IssueActivity"
        android:screenOrientation="portrait"/>
    <activity android:name=".IssueEdit"
        android:screenOrientation="portrait"/>
    <activity android:name=".SpecificationEdit"
        android:screenOrientation="portrait"/>
    <activity android:name=".ExportActivity"
        android:screenOrientation="portrait"/>

</application>

</manifest>
4

1 に答える 1

-2

親レイアウトの背景色を次のように黒に設定するだけです:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@android:color/black">

または、アプリのテーマを次のように設定します。

Theme.Black.NoTitleBar

それがうまく見えることを願っています。

于 2013-02-11T12:49:26.517 に答える