2011-11-02 49 views
2

我有XML文件,并创建视图,我通过该屏幕截图在下一activity.and也有主版面的图像。Android从xml布局获取Main Relativelayout的图像?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" android:id="@+id/mainLayout" 
    android:layout_height="match_parent"> 

    <ImageView android:layout_height="wrap_content" android:id="@+id/imageSelected" 
     android:src="@drawable/icon" android:layout_width="wrap_content" 
     android:layout_centerVertical="true" android:layout_alignParentLeft="true" 
     android:layout_marginLeft="79dp"></ImageView> 

    <RelativeLayout android:layout_width="fill_parent" 
     android:id="@+id/relativelayoutfinal" android:layout_height="fill_parent"> 
    </RelativeLayout> 

    <RelativeLayout android:id="@+id/RelativeLayoutbutton" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true"> 
     <include layout="@layout/bottombutton" /> 
    </RelativeLayout> 

    <Button android:layout_width="wrap_content" android:background="@drawable/b_brightness_contrast" 
     android:id="@+id/btnbrightcont" android:layout_height="wrap_content" 
     android:layout_marginBottom="40dip" android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" android:layout_marginRight="103dp"></Button> 
    <Button android:background="@drawable/b_adjust_and_scale" 
     android:layout_width="wrap_content" android:id="@+id/btnadjustscale" 
     android:layout_above="@+id/btnbrightcont" android:layout_alignLeft="@+id/btnbrightcont" 
     android:layout_height="wrap_content"></Button> 

    <SeekBar android:layout_height="wrap_content" android:progress="50" 
     android:layout_marginTop="50dip" android:layout_marginRight="30dip" 
     android:layout_width="160dip" android:id="@+id/sbbrightness" 
     android:visibility="gone" android:layout_alignParentTop="true" 
     android:layout_alignParentRight="true"></SeekBar> 
    <SeekBar android:layout_height="wrap_content" android:progress="50" 
     android:visibility="gone" android:layout_width="160dip" android:id="@+id/sbcontrast" 
     android:layout_below="@+id/sbbrightness" android:layout_alignLeft="@+id/sbbrightness"></SeekBar> 
</RelativeLayout> 

只是发送图像作为drawable或位图到下一个活动...它的可能??

回答

10

据我了解,您希望您的RelativeLayout XML的屏幕截图:

为此,您可以使用:

View v = yourrelativelayout.getRootView(); 
      v.setDrawingCacheEnabled(true); 
      Bitmap bitmap = v.getDrawingCache(); 
      BitmapDrawable drawable=new BitmapDrawable(bitmap); 

您可以使用此BitmapDrawable作为绘制对象,并能传递到下一个活动。

希望它有帮助。

+0

thanx这么多...你是绝对正确的...... –

+0

但是当我通过bitmapdrawable到其他活动可以设置填充父视图和视图不一样这个视图/// –

+0

这意味着当你使用这个bitmapdrawable ,你可以使用fillparent和setbackground的布局,所以它来全屏幕..你问? – Udaykiran