[英]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.