Java Android-将XML布局堆叠在彼此的顶部
我叫库珀。大约一个月前对java相当陌生 如果你想去哪里看instagram,他们会把图片堆叠在图片上,并附上评论等 看起来XML布局只是复制并粘贴在彼此的顶部 这就是他们正在做的吗?Java Android-将XML布局堆叠在彼此的顶部,java,android,Java,Android,我叫库珀。大约一个月前对java相当陌生 如果你想去哪里看instagram,他们会把图片堆叠在图片上,并附上评论等 看起来XML布局只是复制并粘贴在彼此的顶部 这就是他们正在做的吗? 如何做到这一点?FrameLayout&RelativeLayout允许您将视图堆叠在彼此之上,z索引是按照它们在代码中添加或在xml中写入的顺序进行的。 布局基本上是带有规则的视图组的扩展,如果要在布局中包含另一个布局,请查看和标记: FrameLayout&RelativeLayout允许您将视图堆叠在彼此之
如何做到这一点?FrameLayout&RelativeLayout允许您将视图堆叠在彼此之上,z索引是按照它们在代码中添加或在xml中写入的顺序进行的。 布局基本上是带有规则的视图组的扩展,如果要在布局中包含另一个布局,请查看和标记:
FrameLayout&RelativeLayout允许您将视图堆叠在彼此之上,z索引是按照它们在代码中添加或在xml中写入的顺序进行的。 布局基本上是带有规则的视图组的扩展,如果要在布局中包含另一个布局,请查看和标记:
下面是一个使用框架布局和一些文本视图的示例。此FrameLayout中的所有视图将显示在0,0坐标处,但在孩子的单个视图的android:layout\u marginLeft/android:layout\u marginStart和android:layout\u marginTop属性的维度中有一个偏移
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="11111111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="6dp"
android:layout_marginStart="6dp" />
<TextView
android:text="2222222"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="12dp"
android:layout_marginStart="12dp" />
<TextView
android:text="3333333"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_marginTop="18dp"
android:layout_marginStart="18dp" />
</FrameLayout>
它看起来像什么:
下面是一个使用框架布局和一些文本视图的示例。此FrameLayout中的所有视图将显示在0,0坐标处,但在孩子的单个视图的android:layout\u marginLeft/android:layout\u marginStart和android:layout\u marginTop属性的维度中有一个偏移
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="11111111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="6dp"
android:layout_marginStart="6dp" />
<TextView
android:text="2222222"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="12dp"
android:layout_marginStart="12dp" />
<TextView
android:text="3333333"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_marginTop="18dp"
android:layout_marginStart="18dp" />
</FrameLayout>
它看起来像什么:
现在我怎么能有例如:布局1以编程方式包含布局1?任何布局都可以使用视图进行充气。充气并检查此问题关于将新视图添加到框架布局例如:现在我怎么能有例如:布局1以编程方式包含布局1?任何布局都可以使用视图进行充气。充气并检查此问题关于将新视图添加到框架布局,例如: