先看下实现什么样的效果图:
textOnImage.png
红色的框代表图片,底部棕色的框代表说明性文字。
那么如何实现上述效果呢?主要用到FramLayout布局,要注意imageView的adjustViewBounds="true",其他属性设置效果可自行测试!。
在xml中代码如下:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/imageName"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<TextView
android:id="@+id/tv_zfb_wx"
android:layout_width="match_parent"
android:layout_height="30dp"
android:textColor="#ffffff"
android:textSize="15sp"
android:text="文字"
android:background="#05050505"
android:layout_gravity="bottom"
android:gravity="center_vertical"
android:paddingLeft="10dp"
/>
</FrameLayout>
网友评论