[英]Android Change rotation of screen
您好,當屏幕正常時,Android手機上的圖像看起來還不錯,但是當我轉向橫向時,它占據了導航標題欄的空間。 另外,當我旋轉手機時,它會將我帶回家庭或主要活動,但我卻沒有。 以下是Main-fragment.XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.fred.yeno.MainFragment">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/puAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/dice" />
</LinearLayout>
</LinearLayout>
多媒體文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fred.yeu">
<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"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
以下是MainFragment.java
package com.example.fred.yenu;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
*/
public class MainFragment extends Fragment {
public MainFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_main, container, false);
}
}
我認為您尚未為Fragment
定義Toolbar
,並且您不知道如何以及何時使用Fragment
。 我建議您下載Android studio(如果有的話,請在最新版本中更新SDK和IDE)。
之后,創建一個包含Blank Activity
的新項目,然后從那里開始您的項目。
之后,如果需要,可以將1,2或N個Fragments
添加到Activity
。
我建議您閱讀下面鏈接到您的官方文件:
如果您閱讀本文檔,則具有啟動應用程序的基本知識,並且可以看到問題已經消失。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.