BigScreenBot Development
Introduction
BigScreenBot is a large-screen version of GreetBot, which supports large-screen display content.
1. Permission issues
BigScreenBot display content must apply for the SYSTEM_ALERT_WINDOW permission of the global pop-up dialog box.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
2. Issues with large screens
Due to the screen adaptation from landscape to portrait mode, the system cannot correctly read the screen information after rotation. Therefore, a coordinate transformation is implemented here to ensure the aspect ratio of the screen is correct. Please refer to the demo code for details.
private int screenWidth = 0;
private float scaleX = 0;
public BSImageDisplay(Context outerContext, Display display) {
super(outerContext, display);
Point pt = new Point();
display.getSize(pt);
screenWidth = pt.y * pt.y / pt.x;
scaleX = pt.x * 1.0f * pt.x / pt.y / pt.y;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bs_image_layout);
//The screen resolution requires a conversion due to the orientation (landscape or portrait) issue, hence the following conversion code is provided. Without this conversion, there would be an aspect ratio mismatch.
//Because there is a problem, we have to rotate the screen, so we have the code below
findViewById(R.id.bg_image_main).getLayoutParams().width = screenWidth;
findViewById(R.id.bg_image_main).setScaleX(scaleX);
........
}