Android:scaleType用法及参数含义

scaleType用法及参数含义

  • 1、scaleType是用来控制图片如何resized/moved来匹配对ImageView的size.
  • 2、参数含义:
    (1)、center:按图片的原来size居中显示,当图片长/宽超过View的长/宽,则截取图片的居中部分显示
    (2)、centerCrop:按比例扩大图片的size居中显示,使得图片长(宽)等于或大于View的长(宽)
    (3)、centerInside:将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽
    (4)、fitCenter:把图片按比例扩大/缩小到View的宽度,居中显示
    (5)、fitEnd:把图片按比例扩大/缩小到View的宽度,显示在View的下部分位置
    (6)、fitStart:把图片按比例扩大/缩小到View的宽度,显示在View的上部分位置
    (7)、fitXY:把图片不按比例扩大/缩小到View的大小显示
    (8)、matrix:用矩阵来绘制,动态缩小放大图片来显示。
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:clipChildren="false" android:gravity="center" android:orientation="horizontal" android:layout_gravity="center"> <ImageView android:id="@+id/btn_playback_play" android:layout_width="@dimen/photopage_playback_btn_width" android:layout_height="@dimen/photopage_playback_btn_height" android:scaleType="centerInside" android:contentDescription="@string/photopage_playback_talkback_play" android:src="@drawable/photopage_playback_play_start_selector"/> <TextView android:id="@+id/tv_normal_playback_progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:textColor="@color/photopage_playback_normal_time_text_color" android:textSize="@dimen/photopage_playback_normal_time_text_size" android:layout_marginStart="@dimen/photopage_playback_normal_time_margin_btn" android:textStyle="normal"/> <com.oplus.gallery.photo_page.widget.seekbar.NormalSeekBar android:id="@+id/sb_playback_progress" android:layout_width="0dp" android:layout_height="@dimen/photopage_playback_normal_seekbar_height" android:layout_weight="1" app:couiSeekBarEnableVibrator="false" app:couiSeekBarProgressColor="@color/photopage_playback_seekbar_primary_color" app:couiSeekBarThumbColor="@color/photopage_playback_seekbar_primary_color" android:id="@+id/tv_normal_playback_progress"他显示时间动态变化00:00到00:01宽度会改变,导致seekbar宽度也发生改变,怎么在改动较小的情况下,不让seekbar的宽度跟着发生改变
最新发布
04-04
``` <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/color_F2E7DB"> <FrameLayout android:id="@+id/fit_status_bar" android:layout_width="match_parent" android:layout_height="53dp" android:alpha="0" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> <LinearLayout android:id="@+id/ll_search" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" android:paddingHorizontal="12dp" android:paddingVertical="12dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <ImageView android:id="@+id/iv_back" android:layout_width="40dp" android:background="@drawable/clickable_white" android:layout_height="40dp" android:padding="8dp" android:scaleType="centerCrop" android:src="@drawable/icon_back" /> <com.stary.cateyes.widget.SearchEditText android:id="@+id/et_search" android:layout_width="0dp" android:layout_weight="1" android:layout_height="32dp" android:layout_marginEnd="15dp" android:layout_marginStart="@dimen/dp_4" /> <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/open_window" android:background="@drawable/icon_window_size"> <TextView android:id="@+id/add" android:layout_width="18dp" android:layout_height="20dp" android:gravity="right|bottom" android:paddingRight="2dp" android:text="9" android:textSize="10sp" android:textColor="#000000" android:textStyle="bold" /> </FrameLayout> </LinearLayout> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rv_type" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/ll_search" /> <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="4dp" android:background="@color/color_D7CCC1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/rv_type" /> <FrameLayout android:id="@+id/fl_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/view" /> </androidx.constraintlayout.widget.ConstraintLayout> </layout>```必须要创建列表项布局文件item_suggestion.xml吗?
03-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值