添加分屏测试功能支持多窗口MainActivity

This commit is contained in:
2026-04-27 19:27:25 +08:00
parent d518ac50a9
commit b44fe3aaf3
7 changed files with 66 additions and 4 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Mon Apr 27 18:32:35 CST 2026
#Mon Apr 27 19:22:37 CST 2026
stageCount=20
libraryProject=libappbase
baseVersion=15.15
publishVersion=15.15.19
buildCount=17
buildCount=26
baseBetaVersion=15.15.20

View File

@@ -16,6 +16,17 @@
android:label="@string/app_name"
android:exported="true"
android:resizeableActivity="true"
android:launchMode="singleTop"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
</activity>
<activity
android:name=".MainActivityAlias"
android:label="@string/app_name"
android:exported="true"
android:resizeableActivity="true"
android:launchMode="singleTop"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
<intent-filter>

View File

@@ -161,5 +161,25 @@ public class MainActivity extends Activity {
Intent aboutIntent = new Intent(getApplicationContext(), AboutActivity.class);
startActivity(aboutIntent);
}
public void onSplitScreenMode(View view) {
LogUtils.d(TAG, "onSplitScreenMode() 分屏测试按钮已点击");
ToastUtils.show("分屏测试:已启动新窗口");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
android.graphics.Rect bounds = new android.graphics.Rect();
getWindow().getDecorView().getDisplay().getRectSize(bounds);
int height = bounds.height();
int width = bounds.width();
bounds.set(0, 0, width, height / 2);
LogUtils.d(TAG, "onSplitScreenMode() 分屏窗口范围: " + bounds);
android.content.Intent intent = new android.content.Intent(this, MainActivityAlias.class);
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
LogUtils.d(TAG, "onSplitScreenMode() 准备启动MainActivityAlias");
android.app.ActivityOptions options = android.app.ActivityOptions.makeBasic();
options.setLaunchBounds(bounds);
startActivity(intent, options.toBundle());
LogUtils.d(TAG, "onSplitScreenMode() MainActivityAlias已启动");
}
}
}

View File

@@ -0,0 +1,17 @@
package cc.winboll.studio.appbase;
import android.os.Bundle;
import android.view.View;
import android.widget.Toolbar;
import cc.winboll.studio.appbase.R;
public class MainActivityAlias extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setActionBar(toolbar);
}
}

View File

@@ -83,6 +83,18 @@
android:onClick="onAboutActivity"
android:layout_margin="10dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="分屏测试"
android:textSize="16sp"
android:textColor="@android:color/white"
android:background="#81C7F5"
android:paddingVertical="12dp"
android:layout_marginHorizontal="24dp"
android:onClick="onSplitScreenMode"
android:layout_margin="10dp"/>
</LinearLayout>
</ScrollView>