【问题标题】:Linear layout in frame refuses to go landscape框架中的线性布局拒绝横向
【发布时间】:2012-08-18 14:44:35
【问题描述】:

我在manifest 中将我的应用程序置于横向模式:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:screenOrientation="landscape"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <activity
        android:name=".VerticalSlideshow"
        android:label="@string/title_activity_prime" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

我有一个FrameLayout,在背景中有一个垂直的ScrollView,它正在嗡嗡作响,还有一个LinearLayout,在前景中有一个ImageView 一些按钮。一切正常,除了前景图像/按钮不会使用模拟器进入横向模式。这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ddffff" >

<ScrollView
    android:id="@+id/horizontal_scrollview_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fadingEdge="none" >

    <LinearLayout
        android:id="@+id/horiztonal_outer_layout_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:orientation="vertical"
        android:paddingBottom="0dp"
        android:paddingTop="0dp" >
    </LinearLayout>
</ScrollView>

<LinearLayout
    android:id="@+id/moving"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/clear"
    android:gravity="center_horizontal"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/truck1" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:layout_weight="0.12"
        android:gravity="right"
        android:orientation="vertical" >

        <ImageButton
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.25"
            android:background="@drawable/carfs"
            android:src="@drawable/clear" />

        <ImageButton
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.25"
            android:background="@drawable/policef"
            android:src="@drawable/clear" />

        <ImageButton
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.25"
            android:background="@drawable/taxif"
            android:src="@drawable/clear" />

        <ImageButton
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.25"
            android:background="@drawable/amulancef"
            android:src="@drawable/clear" />
    </LinearLayout>
</LinearLayout>

</FrameLayout>

Eclipse 中的 XML 预览看起来不错。我应该在真手机上测试吗?最终,我怎样才能将此线性视图强制为横向?

【问题讨论】:

    标签: android scrollview android-linearlayout frames


    【解决方案1】:

    尝试将 android:screenOrientation="landscape" 放在您的活动标签中,而不是清单文件中的应用标签中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-11
      相关资源
      最近更新 更多