I am trying to use
https://github.com/nisrulz/screenshott
library to take screenshot.
But it gives error.
Attempt to invoke virtual method 'void android.view.View.measure(int, int)' on a null object reference
Relativelayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context="x.y.z"
android:orientation="vertical"
android:id="@+id/layoutview">
<!--
<com.google.android.gms.ads.AdView
android:id="@+id/adViewChat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="x">
</com.google.android.gms.ads.AdView>
-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="English"
android:background="@drawable/shape"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp"
android:textAlignment="center"
android:id="@+id/textviewtop"
android:layout_marginTop="@dimen/_5sdp"
android:textColor="#ffffff"
android:textStyle="bold"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:orientation="vertical"
android:layout_above="@+id/linear"
android:layout_marginBottom="@dimen/_5sdp"
android:layout_below="@+id/textviewtop"
android:layout_marginTop="@dimen/_5sdp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/_15sdp"
android:background="@drawable/shape"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/welcome"
android:id="@+id/textView"
android:textColor="#ffffff"/>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp"
android:background="@drawable/shape"
android:id="@+id/linear">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:textColor="#ffffff"
android:layout_weight="0.9"
android:hint="Write a message"
android:textColorHint="#A4A4A4"/>
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="send"
android:id="@+id/btn_send"
android:layout_weight="0.1"
android:textColor="#ffffff"
/>
</LinearLayout>
</RelativeLayout>
in OnCreate
Method:
setContentView(R.layout.activity_main);
View myView =(RelativeLayout) findViewById(R.id.layoutview);
Bitmap bitmap_view =
ScreenShott.getInstance().takeScreenShotOfView(myView); // problematic line, this line gives the error.
How can I solve my problem? How can I get relative layout view?