FrameLayout是做什么的? [英] What does FrameLayout do?

查看:122
本文介绍了FrameLayout是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手.我使用的是Graphical Layout,然后在读取xml文件时,看到了FrameLayout.然后我搜索了一下,但是找不到有用的东西.什么是FrameLayout?它有什么作用?

I'm new to programming. I was using Graphical Layout then when I was reading xml file, I saw FrameLayout. Then I searched, but I couldn't find something useful. What is FrameLayout and what does it do?

推荐答案

您使用FrameLayout将子视图彼此堆叠,而最新的子视图则堆叠在栈顶.在下面的示例中,TextView是最新的,因此它会自动放置在ImageView的顶部.

You use a FrameLayout to stack child views on top of each other, with the most recent child on top of the stack. In the example below, the TextView is the most recent, so it is automatically placed on top of the 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>

输出:

这篇关于FrameLayout是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆