Java 当我不希望活动重新启动时,如何修复OnConfiguration Changed中的布局
因此,我在更改方向时修复了活动重新启动(我需要根据客户要求这样做),但现在我在修复显示布局时遇到了问题。我尝试了很多组合Java 当我不希望活动重新启动时,如何修复OnConfiguration Changed中的布局,java,android,android-layout,Java,Android,Android Layout,因此,我在更改方向时修复了活动重新启动(我需要根据客户要求这样做),但现在我在修复显示布局时遇到了问题。我尝试了很多组合layout\u height和layout\u weight,但都失败了 我只是需要一些关于如何解决这个问题的指导 我的布局xml: <?xml version="1.0" encoding="UTF-8"?> <!-- /* Session screen layout Copyright 2013 Thincast Technologies
layout\u height
和layout\u weight
,但都失败了
我只是需要一些关于如何解决这个问题的指导
我的布局xml:
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
Session screen layout
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/session_root_view"
android:background="#F7FE2E"
>
<!-- childs are specified bottom-up so that we have a correct z-order in our final layout -->
<android.inputmethodservice.KeyboardView
android:id="@+id/extended_keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"
/>
<com.freerdp.freerdpcore.presentation.ScrollView2D
android:id="@+id/sessionScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/extended_keyboard"
android:scrollbars="horizontal|vertical"
android:layout_alignParentTop="true"
android:fillViewport="true"
android:background="#FF0040"
android:drawingCacheQuality="high"
android:isScrollContainer="true"
>
<com.freerdp.freerdpcore.presentation.SessionView
android:id="@+id/sessionView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:drawingCacheQuality="high"
/>
</com.freerdp.freerdpcore.presentation.ScrollView2D>
<com.freerdp.freerdpcore.presentation.TouchPointerView
android:id="@+id/touchPointerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/touch_pointer_default"
android:visibility="invisible"
/>
<android.widget.ZoomControls
android:id="@+id/zoomControls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/sessionScrollView"
android:layout_centerHorizontal="true"
/>
<android.inputmethodservice.KeyboardView
android:id="@+id/extended_keyboard_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="gone"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
最初处于纵向时的屏幕截图:
处于横向时的屏幕截图:
谢谢。您的视图可能会在屏幕上填充填充父视图。但纵向纵横比图像不适合作为景观布局的背景 使用不同的景观宽度和高度图像,并在可绘制土地文件夹中使用(图像名称应相同) 来自可绘制土地的图像将自动拾取用于景观布局
LayoutParams p = scrollView.getLayoutParams();
LayoutParams p1 = sessionView.getLayoutParams();
DisplayMetrics outMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
p.width = outMetrics.widthPixels;
p.height = outMetrics.heightPixels
p1.width = outMetrics.widthPixels;
p1.height = outMetrics.heightPixels
您希望您的布局在横向模式下看起来如何?或者你只是想让你的应用程序只固定纵向模式?我希望布局完全显示内部视图(匹配父视图)…它应该自动固定其宽度和高度,但不知何故,这不起作用图像不按填充宽度缩放。您需要创建可绘制的xml。它不是图像。。它实际上是一个自定义的
视图
。那么那辆车的背景是什么?您想在横向模式中填充什么?实际上是远程桌面,在sessionView
中,您可能需要详细解释一下如何获取远程桌面的快照。问题是如何使它适合布局。它应该可以工作。您的onConfigurationChanged
是否被调用?或者,您可以创建一个类似的布局,并将其放置在layout land文件夹中。是的,它确实被调用。我将尝试layout land
方式,然后返回sha Allah。
LayoutParams p = scrollView.getLayoutParams();
LayoutParams p1 = sessionView.getLayoutParams();
DisplayMetrics outMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
p.width = outMetrics.widthPixels;
p.height = outMetrics.heightPixels
p1.width = outMetrics.widthPixels;
p1.height = outMetrics.heightPixels