我是编程新手。 我被用于Graphical Layout,然后当我读取xml文件时,我看到了FrameLayout。然后我搜索了,但我找不到有用的东西。 FrameLayout是什么?它有什么作用?FrameLayout是做什么的?
回答
基本上它提出一个观点上的另一例如顶部:
上的图像文字充气
<FrameLayout>
<ImageView>
<Textview>
</FrameLayout>
你的意思是它像linearlayout一样工作? – 2014-09-05 06:07:27
nope linearlayout放置一个又一个......在它上面的框架位置..小样对于像图像上有网格并且在该图像顶部有取消按钮的senario说.....那里我们使用框架布局 – KOTIOS 2014-09-05 08:18:54
你确定你用Google搜索吗?
帧布局被设计为阻挡的区域中的屏幕上显示单个项目。通常情况下,应该使用FrameLayout来保存单个子视图,因为可以很容易地组织子视图,这种方式可以根据不同的屏幕尺寸进行扩展,而不需要儿童相互重叠。 layout_gravity属性:
你可以,但是,多个孩子中使用Android重力分配给每个 孩子,添加到的FrameLayout和控制 的的FrameLayout中的位置。
FrameLayout里的秘密是如何布局的孩子。虽然通常设计为包含一个 项目,但它会愉快地将其他元素堆叠在一起。因此,FrameLayout本质上是一种操纵屏幕上 视图的Z顺序的方法。
这对于HUD类元素 中的几个UI技巧将滑动面板滑动到更复杂的动画过渡时非常有用。在这篇文章 我们将看到每个人的例子。
的FrameLayout被设计为在一次显示的单个项目。你可以在FrameLayout中有多个元素,但是每个元素都是 ,它们是基于屏幕左上角的。与 重叠的元素将显示为重叠。我使用FrameLayout创建了一个简单的XML布局 ,它显示了这是如何工作的。
您可以使用FrameLayout将子视图堆叠在彼此的顶部,最近的子项位于堆栈顶部。在下面的例子中,TextView是最新的,所以它自动放置在ImageView的顶部。
例如:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/backgroundImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/bitmapie" />
<TextView
android:id="@+id/descTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="70dp"
android:background="@android:color/holo_blue_light"
android:padding="10dp"
android:text="TextView placed at the top of the Imageview"
android:textColor="@android:color/white"
android:textSize="22sp" />
</FrameLayout>
输出:
我喜欢用他们的输出来看代码。非常感谢! Upvoted。另外,我喜欢你在那里做的设计。简单但非常好! – Tarik 2017-12-01 19:55:34
@Tarik谢谢。我觉得有关布局的问题应该有显示输出不只是代码的答案,这就是为什么我尽可能地尝试展示东西如何与图片一起工作的原因。 – 2018-01-14 08:52:32
你可以考虑作为普通相框的话frame
。你用这个框架做什么?您可以将照片放在该框架的顶部到另一个框架中。与FrameLayout
相同,我们可以将视图(任何布局或小部件,如按钮,文本,图像等)放在其他顶部,如@ojonugwa向您显示图像的textview顶部。
不错,我正在考虑将它作为一个'iframe',因为我是从web开发而来的。感谢最简单的解释。 – Tarik 2017-12-01 19:54:51
框架布局旨在屏蔽屏幕上的区域以显示单个项目。通常情况下,应该使用FrameLayout来保存单个子视图,因为可以很容易地组织子视图,这种方式可以根据不同的屏幕尺寸进行扩展,而不需要儿童相互重叠。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/ic_launcher"
android:scaleType="fitCenter"
android:layout_height="250px"
android:layout_width="250px"/>
<TextView
android:text="Frame Demo"
android:textSize="30px"
android:textStyle="bold"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:gravity="center"/>
</FrameLayout>
- 1. 什么“?”做?什么是__FILE__?
- 2. 什么是setDetailItem:做什么?
- 3. 这是做什么
- 4. 什么是random.random做
- 5. page.driver.reset是什么!做?
- 6. 什么是“GCMRegsistrar.register”做
- 7. 是什么[popViewControllerAnimated];做?
- 8. KeyboardView.closing()是做什么的?
- 9. “gcc -xW”是做什么的?
- 10. 这是做什么用的?
- 11. “disableplugins = pnat”是做什么的?
- 12. clog()的做法是什么?
- 13. CG_INLINE是做什么的?
- 14. fork =“true”是做什么的?
- 15. 嘲笑是做什么的?
- 16. AsynchronousExit()是做什么的?
- 17. NHibernateUtil.Initialize是做什么的?
- 18. “mro()”是做什么的?
- 19. APIENTRY是做什么的?
- 20. AutoFac:PropertyWiringFlags.AllowCircularDependencies是做什么的?
- 21. WS_EX_APPWINDOW是做什么的?
- 22. dis.findlabels()是做什么的?
- 23. postInvalidate()是做什么的?
- 24. class_getClassVariable()是做什么的?
- 25. concatMap是做什么的?
- 26. Pyvmomi这是做什么的?
- 27. adodb:createparameter是做什么的?
- 28. GL_COLOR_ATTACHMENT是做什么用的?
- 29. stringWithUTF8String是做什么的?
- 30. pg_basebackup是做什么的?
你有过来过这里吗? http://developer.android.com/reference/android/widget/FrameLayout.html – 2014-09-05 05:57:35
是的,我一直在那里,但我找不到可以理解的东西。 – 2014-09-05 06:23:32