次のコードがあります。
llColors = (LinearLayout) findViewById(R.id.llColorSpect);
llColors.setOnTouchListener(llTouch);
width = llColors.getWidth();
height = llColors.getHeight();
Log.i("LAYOUT WIDTH", "width" +width); //shows 0
Log.i("LAYOUT HEIGHT", "height" +h); //shows the correct height
私を混乱させているのは、なぜ がLAYOUT WIDTH
0 なのかということです。XML では、レイアウトの幅を にmatch_parent
、高さをに設定していますwrap_content
。
Bitmap
以下でデコードし、幅fill_parentの上のレイアウトを埋めるにはどうすればよいですか? LayoutParams を使用しますか?
bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.palette2);
XML コードは次のとおりです。
<LinearLayout
android:id="@+id/llColorSpect"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/palette2"
android:layout_alignParentBottom="true" >
</LinearLayout>
私が達成しようとしているのは、リーマン用語で、レイアウトを取得して背景画像で塗りつぶし、ピクセルを使用して X 座標と Y 座標を取得することです。