在练习android时,想在Linearlayout内放一图片,使其图片置顶,预期效果是这样的:

android linearlayout imageview置顶摆放

 

  

但xml代码imageview写成这样后,

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/moegirl_help"

                />

 

效果却是这样的

android linearlayout imageview置顶摆放

 

试了些方法,包括改为RelativeLayout布局,调整layout_grativity等,直到想起来有ScaleType这个方法:

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/moegirl_help"
                android:scaleType="fitStart"
                />

 scaleType属性值为fitStart,则图片置顶对齐;

 scaleType属性值为fitEnd,则图片置底对齐;

 scaleType属性值为fitXY,则图片拉伸铺满全屏。

相关文章:

  • 2021-06-14
  • 2022-02-08
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
猜你喜欢
  • 2022-01-05
  • 2022-12-23
  • 2021-10-01
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案