由网友(8.取一盏清酒)分享简介:我在开发,我想利用当前屏幕的截屏但标题栏的应用程序。我知道code捕获的截图,但无法对其进行自定义。I am developing an app in that I want to take a screen shot of current screen but with out title bar. I know...
我在开发,我想利用当前屏幕的截屏但标题栏的应用程序。我知道code捕获的截图,但无法对其进行自定义。
I am developing an app in that I want to take a screen shot of current screen but with out title bar. I know the code to Capture a ScreenShot, but unable to customize it.
code:
munchscreen.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
View v1 = L1.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
image = (ImageView) findViewById(R.id.screenshots);
image.setBackgroundDrawable(bitmapDrawable);
}
});
当我点击剪辑
那么就应该抓住以下画面的截图,但不应包括我已经盘旋部分。
When I click on Clip
then it should capture a screen shot of the screen shown below but should not include the part which I have circled..
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#D8D5AA"
>
<LinearLayout
android:id="@+id/clip_from_web_linearlayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/header"
android:orientation="horizontal"
>
<TextView
android:id="@+id/clip_from_web_textview_back"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Back"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:textColor="#FFFFFF"
android:textSize="18sp"
/>
<TextView
android:id="@+id/clip_from_web_textview_header_title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Clip From Web"
android:layout_gravity="center"
android:layout_marginLeft="60dp"
android:textColor="#FFFFFF"
android:textSize="18sp"
/>
<TextView
android:id="@+id/clip_from_web_textview_clip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Clip"
android:layout_gravity="center"
android:layout_marginLeft="60dp"
android:textColor="#FFFFFF"
android:textSize="18sp"
/>
</LinearLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/munch"
android:id="@+id/munchscreen"
android:layout_below="@+id/clip_from_web_linearlayout1"
/>
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/screenshots"
android:layout_below="@+id/munchscreen"
android:contentDescription="@string/app_name"
android:layout_centerInParent="true"
/>
<RelativeLayout
android:id="@+id/clip_from_web_bottom_bar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@drawable/header" >
<Button
android:id="@+id/clip_from_web_previous"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="4dp"
android:background="@android:drawable/ic_media_previous"
android:layout_marginTop="2dp"
/>
<Button
android:id="@+id/clip_from_web_reload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@android:drawable/ic_menu_rotate"
android:layout_marginTop="5dp"
/>
<Button
android:id="@+id/clip_from_web_next"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toRightOf="@+id/clip_from_web_reload"
android:layout_marginLeft="102dp"
android:background="@android:drawable/ic_media_next"
android:layout_marginTop="2dp"
/>
</RelativeLayout>
捕获屏幕快照之前图片。
Image before Capturing screen shot..
捕获屏幕快照图像后..
Image after Capturing screen shot..
推荐答案
拿这个去另一个线性布局
Take this to another Linear Layout
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/munch"
android:id="@+id/munchscreen"
/>
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/screenshots"
android:contentDescription="@string/app_name"
/>
</LinearLayout>
现在找到ID为这个线性布局上onCreate()方法使得它的全局变量
Now find Id for this Linear Layout on oncreate() method making it global variable
LinearLayout ll;
ll = (LinearLayout)findViewById(R.id.linear);
现在抓住这个屏幕
ll.setDrawingCacheEnabled(true);
ll.buildDrawingCache(true);
Bitmap cs = Bitmap.createBitmap(ll.getDrawingCache());
ll.setDrawingCacheEnabled(false);
现在设置这个位图到您的ImageView。
Now set this bitmap to your ImageView.
相关推荐
最新文章