如何在我的Andr​​oid布局创建覆盖按钮 [英] How do i create overlay button in my Android layout

查看:219
本文介绍了如何在我的Andr​​oid布局创建覆盖按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个按钮,将2布局之间叠加。
我使用的线性布局,并添加适当的重量吧。
连接了屏幕截图,以供参考。

下面是我的XML
tag.xml:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:比重=中心
机器人:方向=垂直
机器人:weightSum =100>< RelativeLayout的
    机器人:layout_width =match_parent
    机器人:layout_height =0dp
    机器人:layout_weight =30
    机器人:背景=@彩色/ greyColor
    机器人:比重=中心>    < ImageView的
        机器人:ID =@ + ID / ximgvwCamera
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:背景=@绘制/ camera_big/>
< / RelativeLayout的><滚动型
    机器人:layout_width =match_parent
    机器人:layout_height =0dp
    机器人:layout_weight =70
    机器人:背景=@机器人:彩色/白>    <的LinearLayout
        机器人:layout_width =match_parent
        机器人:layout_height =0dp
        机器人:背景=@机器人:彩色/白
        机器人:重力=CENTER_HORIZONTAL
        机器人:方向=垂直>        <的TextView
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =CENTER_HORIZONTAL
            机器人:layout_margin =5DP
            机器人:填充=5DP
            机器人:文字=@字符串/ strQ1
            机器人:textAppearance =@安卓风格/ TextAppearance.Medium
            机器人:文字颜色=@机器人:彩色/ darker_gray/>
    < / LinearLayout中>
< /滚动型>

请帮我在这。
在此先感谢!


解决方案

试试这个它会工作...

 <的FrameLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直><的LinearLayout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=垂直>    <的LinearLayout
        机器人:layout_width =match_parent
        机器人:layout_height =150dp>        < ImageView的
            机器人:ID =@ + ID / imageCover
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            机器人:scaleType =fitXY
            机器人:SRC =@绘制/ image_top/>
    < / LinearLayout中>    <的LinearLayout
        机器人:layout_width =match_parent
        机器人:背景=@绘制/ image_bottom
        机器人:layout_height =match_parent>
    < / LinearLayout中>
< / LinearLayout中>< ImageView的
    机器人:ID =@ + ID / imageProfile
    机器人:layout_width =100dp
    机器人:layout_height =100dp
    机器人:layout_gravity =结束
    机器人:layout_marginTop =100dp
    机器人:SRC =@绘制/ ic_launcher/>< /&的FrameLayout GT;

查看类似这样

I want to create a button which will overlay between 2 layouts. I am using Linear Layout and added appropriate weight to it. Have attached a screen shot for reference.

Here is my XML tag.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:weightSum="100" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="30"
    android:background="@color/greyColor"
    android:gravity="center" >

    <ImageView
        android:id="@+id/ximgvwCamera"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/camera_big" />
</RelativeLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="70"
    android:background="@android:color/white" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@android:color/white"
        android:gravity="center_horizontal"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_margin="5dp"
            android:padding="5dp"
            android:text="@string/strQ1"
            android:textAppearance="@android:style/TextAppearance.Medium"
            android:textColor="@android:color/darker_gray" />
    </LinearLayout>
</ScrollView>

Please help me in this. Thanks in advance!

解决方案

Try this it will working...

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="150dp" >

        <ImageView
            android:id="@+id/imageCover"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            android:src="@drawable/image_top" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:background="@drawable/image_bottom"
        android:layout_height="match_parent" >
    </LinearLayout>
</LinearLayout>

<ImageView
    android:id="@+id/imageProfile"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="end"
    android:layout_marginTop="100dp"
    android:src="@drawable/ic_launcher" />

</FrameLayout>

View like this

这篇关于如何在我的Andr​​oid布局创建覆盖按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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