【问题标题】:How to repeat image on view如何在视图上重复图像
【发布时间】:2018-08-31 20:47:16
【问题描述】:

我正在尝试在 ImageView 上重复图像。 我尝试在 imageView 上使用位图作为src,但问题是在不同的屏幕尺寸上重复正在改变,我需要修复它并且在所有屏幕尺寸上看起来都一样,请帮助

到目前为止我做了什么

图像视图

<ImageView
        android:src="@drawable/test"
        android:scaleType="fitXY"
        android:layout_width="match_parent"
        android:layout_height="25dp"
        android:background="@color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/item_event_category_calender3"
        app:layout_constraintVertical_bias="0.0" />

和位图

<bitmap
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/circle_grey_new"
        android:tileMode="repeat"
        android:dither="true"/>

【问题讨论】:

    标签: java android xml kotlin


    【解决方案1】:

    此图像位于可绘制文件夹中。将 png 文件放置在下面的 ImageView 中的语法

        <ImageView
        android:id="@+id/ivLogo"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_marginStart="32dp"
        android:layout_marginTop="180dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/devslopesprofilelogo" />
    

    你需要同一张图片的hdpi、mdpi、xhdpi、xxhdpi、xxxhdpi 如果您正在为 Pixil-C 平板电脑设计 xxhdpi 将被使用 如果您正在设计 Nexus 5 手机,将使用 hdpi 所有这些尺寸都在文件夹 devslopesprofilelogo 中,扩展名附加到相应的 png 文件图像中

    最好使用约束布局如果图像是位图,这种类型的图像应该也是如此

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-03
      • 1970-01-01
      • 2017-01-19
      • 1970-01-01
      • 2015-09-30
      • 1970-01-01
      • 2016-08-16
      • 2020-09-10
      相关资源
      最近更新 更多