繁体   English   中英

如何在Android的选项卡式条下面使用imageview放置图像?

[英]How to place a image using imageview below tabbed bar in android?

我正在使用约束布局。 当我将图像放置在图像视图中时,它直接垂直对齐屏幕的中心,在选项卡栏和图像之间留有很大的空间。 我无法将其恰好放在标签栏下方。图像分辨率为2048 * 1152。 我正在计划将其用作我的应用程序的横幅。 这是代码:

<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.manu.program.MainTwo">

<ImageView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:srcCompat="@drawable/banner_image"
    />

</android.support.constraint.ConstraintLayout>

当我运行该应用程序时,我得到的结果如下图所示, 需要删除该图像和标签栏之间的空间

要将图片放置在标签下,可以使用“ android:scaleType =” fitStart“。它将使图片进入顶部,而不会影响任何长宽比。

<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.AppCompatImageView
    android:id="@+id/section_label"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginBottom="0dp"
    android:layout_marginLeft="0dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="0dp"
    android:scaleType="fitStart"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0"
    app:srcCompat="@drawable/flower" />

</android.support.constraint.ConstraintLayout>

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM