這是一個學校項目,但我不明白這個的很多部分。如何使應用程序在AVD中旋轉
但是在描述2個佈局(標準和橫向模式)後,我將旋轉的處理留給了系統 但是當我旋轉屏幕時,橫向模式佈局不會被考慮在內。
http://img15.hostingpics.net/pics/647131Capturedu20160327204339.png
(我已按下按鈕4,在情況下,它是問題......)
在MainActivity擴展AppCompatActivity
,(因爲我們的老師告訴我們),以及所有我做的(現在)在MainActivity是
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG,"Test");
}
然後我描述2個LinearLayouts,一個在佈局/ activity_main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:baselineAligned="false"
android:divider="@drawable/empty_divider_tall"
android:showDividers="middle"
android:background="@color/fl_concrete"
>
<fragment
class="com.example.g20901528.androidproject.fragment.TopFragment"
android:id="@+id/fragment_top"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
<fragment
class="com.example.g20901528.androidproject.fragment.BottomFragment"
android:id="@+id/fragment_bottom"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
,另一個在佈局,土地/活動的main.xml中這幾乎是相同的: 編輯:佈局土地/ activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
android:divider="@drawable/empty_divider_wide"
android:showDividers="middle"
android:background="@color/fl_concrete"
>
<fragment
class="com.example.g20901528.androidproject.fragment.TopFragment"
android:id="@+id/fragment_top"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
<fragment
class="com.example.g20901528.androidproject.fragment.BottomFragment"
android:id="@+id/fragment_bottom"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
我沒有改變我的清單一邊描述在MainActivity:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.g20901528.androidproject">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我的問題是:如何使它在我旋轉手機時旋轉兩個碎片?
我準備好提供任何信息。
Github Link of the project,如果你真的需要它。
確實不錯,不幸的是,它在我的文件系統中都是activity_main.xml。 –