Aya*_*avi 6 android android-layout
我有我的app活动的xml结构.现在我想用id layer1Front以编程方式删除子RelativeLayout.我将如何在代码中执行此操作.我不想隐藏它,我需要删除它,因为我的应用程序中的内存问题.删除它后,我的应用程序会比现在的更轻,更快吗?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layer1Front" >
</RelativeLayout>
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content">
<FrameLayout android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/parallaxLayers"
android:visibility="gone">
</FrameLayout>
</HorizontalScrollView>
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frontView">
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Ale*_*tin 31
最简单的是
findViewById(R.id.layer1front).setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)
但是你也可以有类似的东西
View root = findViewById(R.id.your_root);
root.removeView(yourViewToRemove);
Run Code Online (Sandbox Code Playgroud)
不,删除后您的应用程序不会更轻或更快
| 归档时间: |
|
| 查看次数: |
22539 次 |
| 最近记录: |