将方向更改为横向时使 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>
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">
</ViewFlipper>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您通常以编程方式将 Activity 置于全屏模式的方式:
但是,我建议使用与当前布局相同的名称创建一个新布局,您将在其中创建一个新布局。更改您的
ViewFlipper
,使其占据整个屏幕,然后将其保存在res/layout-land
目录中。This is how you usually put an activity in fullscreen mode programmatically:
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 theres/layout-land
directory.为了达到相同的效果,我创建了一个与较小的 ViewFlipper 同步的全尺寸不可见视图(即它们始终显示相同的图像),并且在切换到横向/纵向模式时显示/隐藏它。
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.