0
<LinearLayout
        android:id="@+id/screenshotlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_weight="4"
        android:orientation="vertical" >

        <GridView
            android:id="@+id/gridview"
            android:background="#ffffff"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:columnWidth="320dp"
            android:gravity="center"
            android:numColumns="1"
            android:verticalSpacing="5dp" />

        <TextView
            android:id="@+id/editText3"
            android:background="@color/DarkGrey"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:layout_gravity="center_horizontal"
            android:gravity="bottom"
            android:text="TextView LinearLayout"
            android:textSize="20dp"
            android:textStyle="bold" >

            <requestFocus />
        </TextView>

    </LinearLayout>

これが私のレイアウトです。Gridview が垂直スクロール バーのように機能する場所。その Gridview にビットマップを動的に追加しています。Gridvies のサイズは異なる場合があります。

4

1 に答える 1

0

これは、レイアウトのビットマップ スクリーンショットを取得する方法です。

  1. レイアウトに ID を追加します (私のものは「スクリーン」と呼ばれます)。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/screen"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >

   <!--//add your buttons, texts, other layouts, etc here-->

</LinearLayout>
  1. これは、プログラムでスクリーン ショットをキャプチャする方法です。

ビュー画面 = 画面 = (ビュー) findViewById(R.id.screen);
ビュー rootview = screen.getRootView();
rootview.setDrawingCacheEnabled(真);

ビットマップ ビットマップ = rootview.getDrawingCache();

これは私にとってはうまくいきました。ImageView でメソッド .setImageBitmap(bitmap) を使用して、スクリーン ショットを表示できます。

于 2013-08-29T09:57:12.763 に答える