将方向更改为横向时,使FlipperView全屏显示

问题描述

| 我有一个
LinearLayout
一个
ViewFlipper
(动态添加图片),里面还有更多东西。横屏时,我只希望全屏显示
ViewFlipper
。那可能吗?我知道我可以使用onConfigurationChanged来检测方向变化,但是我不知道是否有可能动态地全屏显示视图。 有人可以帮忙吗? 谢谢
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
    android:id=\"@+id/item_detail\" android:layout_width=\"fill_parent\"
    android:layout_height=\"fill_parent\" android:background=\"#FFFFFF\">

    <RelativeLayout android:id=\"@+id/top_bar\"
        android:layout_width=\"fill_parent\" android:layout_height=\"44dp\"
        android:background=\"@drawable/nav_bar\">
        <ImageButton android:id=\"@+id/btn_map\"
            android:layout_width=\"34dp\" android:layout_height=\"34dp\"
            android:src=\"@drawable/btn_map\"
            android:layout_centerVertical=\"true\"
            android:layout_alignParentRight=\"true\"
            android:layout_marginRight=\"10dp\" />
        <TextView android:id=\"@+id/top_bar_title\"
            android:layout_width=\"200dp\" android:layout_height=\"wrap_content\"
            android:layout_centerVertical=\"true\" android:gravity=\"center\"
            android:textSize=\"16sp\" android:textColor=\"#FFFFFF\"
            android:textStyle=\"bold\" android:layout_marginLeft=\"60dp\" />
    </RelativeLayout>

    <ScrollView android:layout_width=\"fill_parent\"
        android:layout_height=\"wrap_content\" android:layout_below=\"@id/top_bar\">

        <LinearLayout android:layout_width=\"fill_parent\"
            android:layout_height=\"200dp\">
            <RelativeLayout android:layout_width=\"fill_parent\"
                android:layout_height=\"200dp\">

                <ViewFlipper android:id=\"@+id/itemdetail_gallery\"
                    android:layout_width=\"fill_parent\"
                    android:layout_height=\"fill_parent\">
                </ViewFlipper>                    
            </RelativeLayout>

        </LinearLayout>
    </ScrollView>

</RelativeLayout>
    

解决方法

        通常,这是您通常以编程方式将活动置于全屏模式的方式:
public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}
但是,我建议您使用与当前名称相同的名称创建一个新的布局,在此您将更改
ViewFlipper
,使其占据所有屏幕,然后将其保存在
res/layout-land
目录中。     ,        为了达到相同的效果,我创建了一个与较小的ViewFlipper同步的全尺寸不可见视图(即,它们始终显示相同的图像),并且在切换到风景/人像模式时显示/隐藏它。     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...