简体   繁体   English

Android 在两个视图之间放置一个图像视图

[英]Android place an image view between two views

I need to create a layout as shown in the image.我需要创建如图所示的布局。 The rounded button with the arrow needs to be exactly between the blue and the gray background.带有箭头的圆形按钮需要恰好位于蓝色和灰色背景之间。 I'm having difficulties placing it without specifying the margins precisely, which is something I don't want to do because there is no guarantee it will look good on all resolutions and devices.如果不精确指定边距,我很难放置它,这是我不想做的事情,因为不能保证它在所有分辨率和设备上看起来都很好。 I would appreciate an xml sample for that我将不胜感激 xml 样本

Thanks!谢谢!在此处输入图像描述

截屏

Use the desired drawable.. hope it works.. you can set width and height according to your need.使用所需的 drawable.. 希望它有效.. 您可以根据需要设置宽度和高度。

<?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:orientation="vertical" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dip"
                android:layout_weight="1"
                android:background="#1b96d9"
                android:orientation="vertical" >
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#e6e6e6"
                android:orientation="vertical" >
            </LinearLayout>
        </LinearLayout>

        <ImageView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/arrow" />
    </FrameLayout>

</LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android 布局:在两个视图之间放置一个视图 - Android layout: place a view between two views 将视图放在顶部和两个视图之间 - Place view on top and between two views 将动态视图垂直放置在两个视图之间 - Place dynamic view between two views vertically 如何在CoordinatorLayout中以垂直排列将视图放置在其他两个视图之间? - How to place a view between two other views in a veritcal arrangement in CoordinatorLayout? Android View性能-在两个视图之间切换 - Android View performance - toggling between two views Android:在两个视图之间设置minDinstance,而在两个视图之间有一个视图 - Android: Set minDinstance between two views while there is a view between them 如何在Android中的其他两个视图之间垂直放置视图? - How to position a view vertically between two other views in android? 试图在两个文本视图之间放置一个ImageView? - Attempting to place an ImageView between two text views? Android 在两个堆叠视图旁边显示一个方形图像视图 - Android display a square image view next to two stacked views Android 布局问题,ImageView 未出现在所需位置(在其他两个视图之间) - Android layout problem, ImageView not appearing in desired place (between two other Views)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM