美文网首页
xml中ImageView上的底部放一个TextView

xml中ImageView上的底部放一个TextView

作者: 微笑中的你 | 来源:发表于2018-05-05 20:25 被阅读0次

    先看下实现什么样的效果图:


    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>
    

    相关文章

      网友评论

          本文标题:xml中ImageView上的底部放一个TextView

          本文链接:https://www.haomeiwen.com/subject/snperftx.html