Why lColorWheel.getWith() method returns 0? I guess that it have something to do with onMeasure event, but i really cant understand from documentation how it works. Where I have to set dimensions for mDrawable?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_light);
ShapeDrawable mDrawable;
ivColorWheel=(ImageView)findViewById(R.id.ivColorWheel);
lColorWheel=findViewById(R.id.lColorWheel);
ld=(LayerDrawable)getResources().getDrawable(R.drawable.colorwheel);
mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.setIntrinsicWidth(lColorWheel.getWidth());
mDrawable.setIntrinsicHeight(lColorWheel.getHeight());
Log.d("lColorWheel.getWidth()",Integer.toString(lColorWheel.getWidth())); //returns 0, why?
Log.d("lColorWheel.getHeight()",Integer.toString(lColorWheel.getHeight())); //returns 0, why ?
and appropiate XML file:
<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"
android:background="@drawable/background"
android:gravity="center_horizontal"
android:addStatesFromChildren="true" >
<RelativeLayout
android:id="@+id/lColorWheel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true">
<ImageView
android:id="@+id/ivColorWheel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:src="@drawable/iconwheel"
/>
<ImageView
android:id="@+id/ivCenterButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:maxHeight="5dp"
android:maxWidth="5dp"
android:onClick="clc"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:src="@drawable/center3" />
</RelativeLayout>
<SeekBar
android:id="@+id/sbColorIntensity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/lColorWheel"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/colorintensitystrip"
android:max="255"
android:maxHeight="-25dp"
android:thumb="@drawable/thumb"
android:thumbOffset="0dp"
/>
<SeekBar
android:id="@+id/sbOrientation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/sbColorIntensity"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/orientationstrip"
android:max="255"
android:maxHeight="-25dp"
android:thumb="@drawable/thumb"
android:thumbOffset="0dp"
/>
<SeekBar
android:id="@+id/sbWhiteIntensity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/sbOrientation"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/whiteintensitystrip"
android:max="255"
android:maxHeight="-25dp"
android:thumb="@drawable/thumb"
android:thumbOffset="0dp"
/>
</RelativeLayout>
thx