refactor: 调整主窗口背景设置逻辑与布局透明度
- MainActivity: 将背景设置逻辑从 onCreate 移至 onPostCreate - activity_main.xml: RecyclerView 背景颜色修改为透明
This commit is contained in:
@@ -51,11 +51,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
LogUtils.d(TAG, "onCreate");
|
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);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
@@ -104,6 +99,15 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
checkAndRequestPermissions();
|
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() {
|
private void checkAndRequestPermissions() {
|
||||||
LogUtils.i(TAG, "checkAndRequestPermissions");
|
LogUtils.i(TAG, "checkAndRequestPermissions");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/black"/>
|
android:background="@android:color/transparent"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user