refactor: 调整主窗口背景设置逻辑与布局透明度

- MainActivity: 将背景设置逻辑从 onCreate 移至 onPostCreate
- activity_main.xml: RecyclerView 背景颜色修改为透明
This commit is contained in:
2026-05-02 10:05:26 +08:00
parent 1585ff7eed
commit 0786d69ad6
2 changed files with 10 additions and 6 deletions

View File

@@ -51,11 +51,6 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
LogUtils.d(TAG, "onCreate");
View content = findViewById(android.R.id.content);
if (content != null) {
content.setBackground(BackgroundUtils.getInstance().getDrawable());
}
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@@ -104,6 +99,15 @@ public class MainActivity extends AppCompatActivity {
checkAndRequestPermissions();
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
View content = findViewById(android.R.id.content);
if (content != null) {
content.setBackground(BackgroundUtils.getInstance().getDrawable());
}
}
private void checkAndRequestPermissions() {
LogUtils.i(TAG, "checkAndRequestPermissions");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {

View File

@@ -27,7 +27,7 @@
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"/>
android:background="@android:color/transparent"/>
</LinearLayout>