Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 风景画_Android_Android Layout - Fatal编程技术网

Android 风景画

Android 风景画,android,android-layout,Android,Android Layout,我一直在这个网站上寻找答案,但我找不到答案。在我的模拟器中,我的android应用程序并没有从纵向切换到横向,它只是显示了一个横向的纵向屏幕。 我制作了一个布局和布局文件夹,其中包含匹配的xml名称等等。但它似乎没有在布局和土地版本上得到重视。我没有onConfig()函数或任何东西,所以我想知道是否有人可以帮助我 mainpage.xml布局图 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android

我一直在这个网站上寻找答案,但我找不到答案。在我的模拟器中,我的android应用程序并没有从纵向切换到横向,它只是显示了一个横向的纵向屏幕。 我制作了一个布局和布局文件夹,其中包含匹配的xml名称等等。但它似乎没有在布局和土地版本上得到重视。我没有onConfig()函数或任何东西,所以我想知道是否有人可以帮助我

mainpage.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="@color/main_background"
    android:gravity="center"
    android:padding="30dip">

    <TextView
        android:id="@+id/main_title_text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/main_title"
        android:textColor="@color/text"
        android:textSize="25sp" />

    <TableLayout
        android:id="@+id/tablelayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:stretchColumns="*">

        <TableRow
            android:layout_height="wrap_content"
            android:layout_width="fill_parent">

            <Button
                android:id="@+id/start_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/start_button"
                android:textColor="@color/text" />

            <Button
                android:id="@+id/help_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/help_button"
                android:textColor="@color/text" />

        </TableRow>

        <TableRow
            android:layout_height="wrap_content"
            android:layout_width="match_parent">

            <Button
                android:id="@+id/extra_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/extra_button"
                android:textColor="@color/text" />

            <Button
                android:id="@+id/stop_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/stop_button"
                android:textColor="@color/text" />

        </TableRow>

    </TableLayout>

</LinearLayout>

这是一个模拟器错误,当您尝试在横向模式下启动活动时,您将看到它将从layout land加载mainpage.xml

android:screenOrientation=“横向”

但是ctrl+f12不起作用,这是一个bug


它有,但我是新来的,所以我对这些帖子不太熟悉,但我两个都有按钮。tyHi这是一个模拟器错误,ctrl+f12不起作用。要测试横向模式,请修改manifest.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="@color/main_background"
    android:gravity="center"
    android:padding="30dip">

    <TextView
        android:id="@+id/main_title_text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/main_title"
        android:textColor="@color/text"
        android:textSize="25sp" />

    <Button
        android:id="@+id/start_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/start_button"
        android:textColor="@color/text" />

    <Button
        android:id="@+id/help_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/help_button"
        android:textColor="@color/text" />

    <Button
        android:id="@+id/extra_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/extra_button"
        android:textColor="@color/text" />

    <Button
        android:id="@+id/stop_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/stop_button"
        android:textColor="@color/text" />

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.MC.ChemPal"
    android:versionCode="1"
    android:versionName="1.0">
    <uses-sdk android:minSdkVersion="10" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".main"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.MC.ChemPal.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".mainpage" android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.MC.ChemPal.MAINPAGE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".Extra"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.MC.ChemPal.EXTRA" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".help"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.MC.ChemPal.HELP" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".search_page"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.MC.ChemPal.SEARCH_PAGE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>
</manifest>
package com.MC.ChemPal;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class mainpage extends Activity {
    /** Called when the activity is first created. */
    Button start_button, help_button, extra_button, stop_button;
    TextView display;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mainpage);

        start_button = (Button) findViewById(R.id.start_button);
        help_button = (Button) findViewById(R.id.help_button);
        extra_button = (Button) findViewById(R.id.extra_button);
        stop_button= (Button) findViewById(R.id.stop_button);
        display = (TextView) findViewById(R.id.main_title_text);

        start_button.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent openSearchPage = new               Intent("com.MC.ChemPal.SEARCH_PAGE");
                startActivity(openSearchPage);
            }
        });
        help_button.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent openHelp = new Intent("com.MC.ChemPal.HELP");
                startActivity(openHelp);
            }
        });
        extra_button.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent openExtra = new Intent("com.MC.ChemPal.EXTRA");
                startActivity(openExtra);
            }
        });
        stop_button.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                onStop();
            }
        });

    }
}