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

但xml代码imageview写成这样后,
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/moegirl_help"
/>
效果却是这样的

试了些方法,包括改为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,则图片拉伸铺满全屏。

浙公网安备 33010602011771号