<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);解决方法 代码似乎是完美的,除了你分配的内容区域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的顶部和中心所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)