Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android将图像放在RelativeLayout的顶部和中心大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将图像与我的相对布局的顶部对齐,然后将其水平对齐.这是我正在使用的代码
<ImageView  
        android:id="@+id/collection_image_BACkground"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"  />

,但此代码无效.我的图像居中,但未在我的相对布局顶部对齐.我尝试使用android:scaleType =“fitStart”,但它实际上是将图像左侧和顶部对齐的父级.

所以任何想法如何我可以正确对齐图像?

附:我忘了提到我正在将图像设置为我的ImageView,如下所示:

BitmapFactory.options o2 = new BitmapFactory.options();
    o2.inTempStorage = new byte[8*1024];

    ops = BitmapFactory.decodeStream(cis,null,o2);
    ImageView view = (ImageView) findViewById(R.id.collection_image_BACkground);
    view.setImageBitmap(ops);
@H_607_13@解决方法
代码似乎是完美的,除了你分配的内容区域fill_parent采用整个视图并将显示为中心,所以只需通过wrap_content修改
<ImageView  
            android:id="@+id/collection_image_BACkground"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"  />

大佬总结

以上是大佬教程为你收集整理的Android将图像放在RelativeLayout的顶部和中心全部内容,希望文章能够帮你解决Android将图像放在RelativeLayout的顶部和中心所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

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