如何在framelayout中设置图像 [英] how to set image inside framelayout

查看:121
本文介绍了如何在framelayout中设置图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在FrameLayout内部设置图像,但与框架布局的背景重叠

I want to set image inside the FrameLayout but is overlapping the framelayout's background

推荐答案

这是示例示例, https://snag .gy/IrawbT.jpg

最后放置在堆栈上的

项目将被绘制在堆栈下面的项目之上. 通过这种布局,可以很容易地在其他布局上进行绘制, 尤其是对于诸如按钮放置之类的任务.

item last put on the stack will be drawn on top of the items below it. This layout makes it very easy to draw on top of other layouts, especially for tasks such as button placement.

要在FrameLayout内安排孩子,请使用 android:layout_gravity属性以及任何android:padding 和您需要的android:margin.

To arrange the children inside of a FrameLayout use the android:layout_gravity attribute along with whatever android:padding and android:margin you need.

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <!-- Child1 is drawn first -->
    <!-- Child2 is drawn over Child1 -->
    <!-- Child3 is drawn over Child1 and Child2 -->
    <TextView
        android:id="@+id/child1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:text="Child 3"
        android:textSize="25sp"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/child2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_margin="40dip"
        android:src="@color/childs"
        android:text="Child 2" />

    <ImageView
        android:id="@+id/child3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="Image"
        android:src="@color/_dark_gray" />
</FrameLayout >

这篇关于如何在framelayout中设置图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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