两个WebView更改拆分方向不重新加载视图
问题描述:
我有两个WebView,当potrait,它位于上方和下方,但横向时,将其分为左和右。两个WebView更改拆分方向不重新加载视图
我已成功创建它,并更改onCreateView
中的方向视图并保持状态,但它会重新加载web视图并显示阻止应用程序显示的加载弹出窗口。我认为有人知道如何在不重新加载应用程序的情况下改变拆分方向?
电流法:
View v = null;
if (getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT) {
v = inflater.inflate(R.layout.fragment_potrait, container, false);
} else {
v = inflater.inflate(R.layout.fragment_landscape, container, false);
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/parent_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
xmlns:spl="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:visibility="gone"
>
<View
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@color/light_gray"
app:layout_scrollFlags="scroll|enterAlways"
/>
</android.support.design.widget.AppBarLayout>
<SplitPaneLayout
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:layout_marginTop="?attr/actionBarSize"
spl:splitterPosition="43%"
spl:orientation="vertical"
spl:splitterBackground="@drawable/splitter_bg_h"
spl:splitterDraggingBackground="#F0F0F0"
>
<WebView
android:id="@+id/webview1"
android:layout_width = "fill_parent"
android:layout_height = "0dp"
android:text = "YOUR FIRST TEXT"
android:layout_weight = "1"
android:autoLink="web|all"
android:scrollbars="none"
android:textColor="@android:color/black"
/>
<WebView
android:id="@+id/webview2"
android:layout_width = "fill_parent"
android:layout_height = "0dp"
android:text = "YOUR SECOND TEXT"
android:autoLink="web|all"
android:scrollbars="none"
android:textColor="@android:color/black"
android:layout_weight = "1"
/>
</SplitPaneLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
我用这个拆分窗格: https://github.com/MobiDevelop/android-split-pane-layout
答
在运行Android的应选择纵向/横向布局。
通过声明:
android:configChanges="keyboardHidden|orientation|screenSize"
onCreate
,和onDestroy
不叫而是onConfigurationChanged
被调用。你可以用这种方法处理你想以编程方式进行的一切!
更多信息,请参阅Handling Configuration Changes
它不回答这个问题是:*?如何**改变分割方向**无需重新加载应用程序* – Selvin