Jul*_*nma 5 xml android preview
我的应用程序有很多视图,它们是片段的容器(加载图像和其他视图),并依赖于API来获取图像.为了使设计的开发更容易,我想在我的xml中添加该图像的样本.现在,我将与FragmentContainer并使用不同的可见度值的虚设ImageView的一个RelativeLayout的android:visibility和tools:visibility.
有没有更好的方法来显示图像只是为了预览目的?我想在发布版本中编译预览视图.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:adjustViewBounds="true"
tools:src="@drawable/image"
tools:visibility="visible" />
<RelativeLayout
android:id="@+id/FragmentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
如果我正确理解你的问题,你可以这样做:不使用虚拟视图,而是使用
<include tools:layout="@layout/layout_preview" layout="@layout/layout_actual"/>
Run Code Online (Sandbox Code Playgroud)
这里layout_preview.xml是任何你想要的只是在预览使用,layout_actual.xml是什么将在应用程序中使用
如果您只想在预览中添加视图,但在应用程序中根本没有视图,则可以使用layout_actual.xml带有空合并标记的视图
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"/>
Run Code Online (Sandbox Code Playgroud)
如果你不想包含无用的布局,你可能只想为调试构建类型创建虚拟布局,它会在布局中显示错误,因为缺少layout_dummy但是因为它是tools属性你应该能够编译和跑
| 归档时间: |
|
| 查看次数: |
1065 次 |
| 最近记录: |