显示两张图片

发布时间:2022-07-05 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了显示两张图片脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

(1)设计方案

显示两张图片

黄色布局包含两个子布局

(2)代码实现

<RelativeLayout XMlns:andROId="http://schemas.android.COM/apk/res/android"
    xMLns:tools="http://schemas.android.com/tools"
    android:layout_width=";match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivITy" >

    <RelativeLayout  
         android:id="@+id/pic1"
         android:layout_width="match_parent"
         android:layout_height="400dp"
         android:background="@drawable/bg1"
        ></RelativeLayout>
    
    <RelativeLayout 
         android:layout_below="@id/pic1"
         android:layout_width="match_parent"
         android:layout_height="400dp"
         android:background="@drawable/bg"
        ></RelativeLayout>
    
    
</RelativeLayout>

 在android:layout_width="match_parent"中match_parent为默认

android:layout_height="400dp"代表,高度为400像素

android:background="@drawable/bg1"代表background要找到drawable文件下的bg1图片

在第一个样式中分配id要用到@+id

在第一个样式中,第二个图片在第一个图片的下方,这时要用到@id,因为是在Pic1的下面

(注F1a;@id后面的名字可以随便起名)

 运行效果

显示两张图片

 ——@上官可编程

 

 

脚本宝典总结

以上是脚本宝典为你收集整理的显示两张图片全部内容,希望文章能够帮你解决显示两张图片所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。