开发者

Make FlipperView fullscreen when changing orientation to landscape

开发者 https://www.devze.com 2023-03-09 14:33 出处:网络
I\'ve got a LinearLayout with a ViewFlipper (with images added dynamically) and more stuff inside. When going landscape I\'d like to only have the ViewFlipper showing fullscreen. Is that possible? I k

I've got a LinearLayout with a ViewFlipper (with images added dynamically) and more stuff inside. When going landscape I'd like to only have the ViewFlipper showing fullscreen. Is that possible? I know that I can use onConfigurationChanged to detect orientation changes, but I don't know if it's possible to make a view fullscreen dynamically.

Anybody can help?

Thanks

<?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">
                </ViewFlipp开发者_高级运维er>                    
            </RelativeLayout>

        </LinearLayout>
    </ScrollView>

</RelativeLayout>


This is how you usually put an activity in fullscreen mode programmatically:

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);
    }
}

However, what I recommend is to create a new layout with the same name that the current one, there you will change your ViewFlipper so that it takes all the screen, then save it in the res/layout-land directory.


To achieve the same effect I created a full size invisible view synchronized with the smaller ViewFlipper (ie they always show the same image), and I show/hide it when switching to landscape/portrait mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消