Indeed, there are solutions and questions has been answered all over the SO. So, here is what I have tried so far!
Scroll_Layout.xml
<ScrollView
android:id="@+id/scrollView"
android:layout_width="0dp"
android:layout_height="0dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="8dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txtAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ADDRESS"
android:textSize="40px"
android:textColor="@android:color/black"/>
<EditText
android:id="@+id/edtName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Enter Address"
android:text="lorem emisidjsi damsodks"/>
<TextView
android:id="@+id/txtPostal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="POSTAL CODE"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<EditText
android:id="@+id/edtPostal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Enter Postal Code"
android:text="123456"/>
<TextView
android:id="@+id/txtCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="CITY / GNR"
android:textColor="@android:color/black"
android:textSize="40px" />
<EditText
android:id="@+id/edtCity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Loresm"
android:hint="Enter City"/>
<TextView
android:id="@+id/txtBnr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BNR"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<EditText
android:id="@+id/edtBnr"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Enter BNR"
android:text="1122"/>
<TextView
android:id="@+id/txtSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SIZE"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<EditText
android:id="@+id/edtSize"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Enter Size"
android:text="50 x 400 x 200"/>
<TextView
android:id="@+id/txtRental"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RENTAL"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="3"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtFull"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Full"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtPartial"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Partial"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtRentalNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/txtBasement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BASEMENT"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="3"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary" />
<TextView
android:id="@+id/txtFurnished"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Furnished"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtUnFurnished"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Un-Furnished"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtBasementNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/txtType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TYPE"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="3"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtDetached"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Detached"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtSemiDetached"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Semi-Detached"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtTownHouse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Town-House"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.AppCompatSpinner
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:entries="@array/arr_add_buildings">
</android.support.v7.widget.AppCompatSpinner>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingRight="20dp">
<TextView
android:id="@+id/txtYear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="YEAR"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<EditText
android:id="@+id/edtYear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Enter Year"
android:text="2011"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/txtBldSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SIZE"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<EditText
android:id="@+id/edtBdlSize"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Enter Size"
android:text="20 x 20"/>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.AppCompatSpinner
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="5dp"
android:entries="@array/arr_deductible">
</android.support.v7.widget.AppCompatSpinner>
<TextView
android:id="@+id/txtCoverage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="COVERAGE"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtNormal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Normal"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="@color/colorPrimary"/>
<TextView
android:id="@+id/txtSuper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Super"
android:textSize="40px"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/txtComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="COMMENTS"
android:textColor="@android:color/black"
android:textSize="40px" />
<EditText
android:id="@+id/edtComments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="white walls"
android:hint="Enter Comments"/>
<Button
android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:text="SAVE"
android:textSize="50px"
android:textColor="@android:color/white"
android:backgroundTint="@color/colorPrimary" />
</LinearLayout>
</ScrollView>
Solution, I have tried so far!
Method 1:
public Bitmap takeScreenshot() {
View rootView = getWindow().getDecorView().findViewById(R.id.scrollView); //Instead of ScrollView I have taken Main view to but no luck
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}
Method 2:
public Bitmap takeScreenshot() {
View rootView = getWindow().getDecorView().findViewById(R.id.constraintLayout); //Here also I have taken ScrollView too.
Bitmap b = Bitmap.createBitmap(rootView.getWidth() , rootView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
rootView.layout(0, 0, rootView.getLayoutParams().width, rootView.getLayoutParams().height);
rootView.draw(c);
return b;
}
Method 3:
public Bitmap takeScreenshot() {
ScrollView iv = (ScrollView) findViewById(R.id.scrollView);
Bitmap bitmap = Bitmap.createBitmap(
iv.getChildAt(0).getWidth(),
iv.getChildAt(0).getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
iv.getChildAt(0).draw(c);
return bitmap;
}
In all the above method, I am having "Black" background screenshot. Apart from these do anyone have other solutions or am I making any mistakes in taking Screenshot?
How do I take a scrolling screenshot on Android? On Android 11 or later, press the power and volume down buttons at the same time. Then, tab the “capture more” option at the bottom left corner of the screen.
Take a scrolling screenshot on your Android To take a scrolling screenshot on Android, navigate to the content screen you'd like to save. Press the power and volume down buttons at the same time to trigger the screenshot tool.
To take a full screen screenshot Windows, follow the steps below: Press and hold Ctrl + Alt together, then press PRTSC. Press and hold the left mouse button, then drag the mouse on the scrolling window to select the area. Release the mouse click, and an auto-scroll will happen slowly.
Because there is no way to natively capture scrolling screenshots on Android (as of Android 11), you will need to rely on third-party apps for this. While you will get a lot of apps when you search for scrolling screenshots on the Google Play Store, one app that seems to be everyone’s favorite is LongShot.
To take a scrolling screenshot on an Android device running Android 12 or higher, first, you need to be in an app that has vertical scrolling. We’ll be using YouTube for this example. From there, press the physical Power+Volume Down buttons until the screen flashes. Next, tap “Capture More” from the screenshot preview menu.
While some smartphone makers such as OnePlus and Xiaomi have an in-built feature that allows users to capture full-page screenshots, some other smartphone makers do not provide this feature. There are several apps available on the Play Store that allow you to capture full-page screenshots.
Download Longshot from the Google Play Store. Install the app and grant all the necessary permissions. In Longshot settings, make sure you tap the checkbox next to “Auto Scroll.” The app will now prompt you to give it additional permissions. Grant all permissions. Open the app and now clock the Blue Camera icon next to “Capture Screenshot.”
I hope this is work for you.. source here
Bitmap bitmap = getBitmapFromView(scrollview, scrollview.getChildAt(0).getHeight(), scrollview.getChildAt(0).getWidth());
//create bitmap from the ScrollView
private Bitmap getBitmapFromView(View view, int height, int width) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Drawable bgDrawable = view.getBackground();
if (bgDrawable != null)
bgDrawable.draw(canvas);
else
canvas.drawColor(Color.WHITE);
view.draw(canvas);
return bitmap;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With