下面是我的code的片段
<?XML版本=1.0编码=UTF-8&GT?;<的FrameLayout的xmlns:机器人=http://schemas.android.com/apk/res/android 机器人:ID =@ + ID / framelayouts 机器人:layout_width =FILL_PARENT 机器人:layout_height =FILL_PARENT 机器人:layout_gravity =中心 > < ImageView的 机器人:ID =@ + ID / imageviews 机器人:layout_width =FILL_PARENT 机器人:layout_height =FILL_PARENT 机器人:layout_gravity =中心 机器人:SRC =@绘制/ ic_launcher/>< /&的FrameLayout GT;
现在能够在中心获取图像。
问题:
下面的问题就是我得到一些未使用的空间,顶部和底部,我怎么能找到图像的未使用的空间或高度或仅imageheight的高度?
截图:
解决方案 私人无效getImageViewDimension(){ // TODO自动生成方法存根 新的处理程序()。postDelayed(新的Runnable(){ @覆盖 公共无效的run(){ INT actualImgWidth = mDeviceWidth - mImgView.getX(); INT actualImgHeight = mDeviceHeight - mImgView.getY(); Toast.makeText(getApplicationContext(),actualImgWidth,actualImgHeight:+ actualImgWidth +,+ actualImgHeight, Toast.LENGTH_SHORT).show(); INT宽度= mImgView.getWidth(); INT高度= mImgView.getHeight(); } },10L);}
Here is my snippet of code
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/framelayouts"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/imageviews"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:src="@drawable/ic_launcher" />
</FrameLayout>
now am able to get the image at center .
Problem:
Here Problem is i am getting some un used space top and bottom, how can i find the height of the unused space or height of the image or only the imageheight ?
Screenshot:
解决方案private void getImageViewDimension() {
// TODO Auto-generated method stub
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
int actualImgWidth = mDeviceWidth - mImgView.getX();
int actualImgHeight = mDeviceHeight - mImgView.getY();
Toast.makeText(getApplicationContext(), "actualImgWidth ,actualImgHeight:" +actualImgWidth +","+actualImgHeight ,
Toast.LENGTH_SHORT).show();
int Width = mImgView.getWidth();
int Height = mImgView.getHeight();
}
}, 10L);
}
上一篇:呼吁.NET 3.5大会第一次通话后,VB6自动化错误错误、大会、NET
下一篇:我可以使用的DataAnnotations我的一个RegularEx pression属性呢?我的、可以使用、属性、DataAnnotations