So I have the following layout called demo_text.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/screen">
<TextView
android:id="@+id/textToDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Hello World"
</FrameLayout>
I am trying to convert this demo_text to a Bitmap. This is my onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View inflatedFrame = getLayoutInflater().inflate(R.layout.demo_text, null);
FrameLayout frameLayout = (FrameLayout) inflatedFrame.findViewById(R.id.screen) ;
frameLayout.setDrawingCacheEnabled(true);
frameLayout.buildDrawingCache();
Bitmap bm = frameLayout.getDrawingCache();
}
I want the bitmap to be the entire layout but the Bitmap is always returning null.