Skip to content

Commit 15fb7ba

Browse files
committed
Fix up the UI demo for ICS
1 parent 16f6c74 commit 15fb7ba

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

AndroidUIDemo/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# project structure.
99

1010
# Project target.
11-
target=android-8
11+
target=android-14

AndroidViewDemo/res/layout/main.xml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<FrameLayout
3+
<LinearLayout
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
android:id="@+id/main"
6-
android:orientation="horizontal"
6+
android:orientation="vertical"
77
android:layout_width="match_parent"
88
android:layout_height="match_parent">
99

1010
<LinearLayout
1111
android:id="@+id/xform_v"
1212
android:orientation="horizontal"
1313
android:layout_width="match_parent"
14-
android:layout_height="match_parent">
14+
android:layout_height="wrap_content">
1515

1616
<LinearLayout
1717
android:id="@+id/xform_v_left"
1818
android:orientation="vertical"
1919
android:background="@drawable/bg0"
20-
android:layout_width="wrap_content"
20+
android:layout_width="0dp"
21+
android:layout_weight=".05"
2122
android:layout_height="wrap_content" />
2223

2324
<LinearLayout
2425
android:id="@+id/xform_v_right"
2526
android:orientation="vertical"
2627
android:background="@drawable/bg0"
27-
android:layout_width="wrap_content"
28+
android:layout_width="0dp"
29+
android:layout_weight=".05"
2830
android:layout_height="wrap_content" />
2931
</LinearLayout>
3032

3133
<LinearLayout
3234
android:id="@+id/efx_v"
3335
android:orientation="horizontal"
3436
android:layout_width="match_parent"
35-
android:layout_height="match_parent">
37+
android:layout_height="wrap_content">
3638

3739
<LinearLayout
3840
android:id="@+id/efx_v_left"
3941
android:orientation="vertical"
4042
android:background="@drawable/bg0"
41-
android:layout_width="wrap_content"
43+
android:layout_width="0dp"
44+
android:layout_weight=".05"
4245
android:layout_height="wrap_content" />
4346

4447
<LinearLayout
4548
android:id="@+id/efx_v_right"
4649
android:orientation="vertical"
4750
android:background="@drawable/bg0"
48-
android:layout_width="wrap_content"
51+
android:layout_width="0dp"
52+
android:layout_weight=".05"
4953
android:layout_height="wrap_content" />
5054
</LinearLayout>
51-
</FrameLayout>
55+
56+
<com.oreilly.demo.android.pa.viewdemo.widget.GLDemoWidget
57+
android:id="@+id/efx_gl"
58+
android:layout_width="match_parent"
59+
android:layout_weight=".03"
60+
android:layout_height="0dp" />
61+
<!--
62+
-->
63+
</LinearLayout>

AndroidViewDemo/src/com/oreilly/demo/android/pa/viewdemo/TransformIt.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ private void buildEfxView(LinearLayout lv, LinearLayout rv) {
153153
new LinearGradient(
154154
0.0F,
155155
0.0F,
156-
160.0F,
157-
80.0F,
156+
100.0F,
157+
10.0F,
158158
new int[] {
159159
Color.BLACK, Color.RED, Color.YELLOW },
160-
new float[] { 0.2F, 0.3F, 0.2F },
160+
new float[] { 0.0F, 0.5F, 0.95F },
161161
Shader.TileMode.REPEAT));
162162
} }));
163163
lv.addView(new EffectsWidget(
@@ -169,10 +169,6 @@ private void buildEfxView(LinearLayout lv, LinearLayout rv) {
169169
new BlurMaskFilter(2, BlurMaskFilter.Blur.NORMAL));
170170
} }));
171171

172-
// the OpenGL widget
173-
glWidget = new GLDemoWidget(this);
174-
lv.addView(glWidget);
175-
176172
rv.addView(new EffectsWidget(
177173
this,
178174
2,
@@ -204,7 +200,6 @@ private void buildEfxView(LinearLayout lv, LinearLayout rv) {
204200
rv.addView(w);
205201
w.setBackgroundResource(R.drawable.throbber);
206202

207-
//!!! Hack; should be fixed in Cupcake
208203
w.setOnClickListener(new OnClickListener() {
209204
@Override public void onClick(View v) {
210205
AnimationDrawable animation

AndroidViewDemo/src/com/oreilly/demo/android/pa/viewdemo/widget/EffectsWidget.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.graphics.Color;
99
import android.graphics.Paint;
1010
import android.view.View;
11+
import android.view.ViewGroup;
1112

1213
import com.oreilly.demo.android.pa.viewdemo.R;
1314

@@ -39,7 +40,7 @@ public EffectsWidget(Context context, int n, PaintEffect pe) {
3940
effect = pe;
4041

4142
setMinimumWidth(160);
42-
setMinimumHeight(80);
43+
setMinimumHeight(135);
4344

4445
setBackgroundResource(R.drawable.bg0);
4546
}
@@ -48,7 +49,7 @@ public EffectsWidget(Context context, int n, PaintEffect pe) {
4849
@Override
4950
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
5051
setMeasuredDimension(
51-
getSuggestedMinimumWidth(),
52+
ViewGroup.LayoutParams.MATCH_PARENT,
5253
getSuggestedMinimumHeight());
5354
}
5455

AndroidViewDemo/src/com/oreilly/demo/android/pa/viewdemo/widget/GLDemoWidget.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import android.opengl.GLU;
1818
import android.opengl.GLUtils;
1919
import android.os.SystemClock;
20+
import android.util.AttributeSet;
2021

2122
import com.example.android.apis.graphics.GLSurfaceView;
2223
import com.oreilly.demo.android.pa.viewdemo.R;
@@ -37,14 +38,12 @@ public class GLDemoWidget extends GLSurfaceView
3738

3839
/**
3940
* @param context the app context
41+
* @param attrs the view attributes
4042
*/
41-
public GLDemoWidget(Context context) {
42-
super(context);
43+
public GLDemoWidget(Context context, AttributeSet attrs) {
44+
super(context, attrs);
4345
this.context = context;
4446

45-
setMinimumWidth(160);
46-
setMinimumHeight(80);
47-
4847
setRenderer(this);
4948

5049
float[] coords = {
@@ -86,14 +85,6 @@ public GLDemoWidget(Context context) {
8685
indexBuf.position(0);
8786
}
8887

89-
/** @see android.view.View#onMeasure(int, int) */
90-
@Override
91-
protected void onMeasure(int widthSpec, int heightSpec) {
92-
setMeasuredDimension(
93-
getSuggestedMinimumWidth(),
94-
getSuggestedMinimumHeight());
95-
}
96-
9788
/**
9889
* We don't need a depth buffer and don't care about our color depth.
9990
*/
@@ -131,7 +122,7 @@ public void surfaceCreated(GL10 gl) {
131122
GL10.GL_PERSPECTIVE_CORRECTION_HINT,
132123
GL10.GL_FASTEST);
133124

134-
gl.glClearColor(0.4f, 0.2f, 0.2f, 0.5f);
125+
gl.glClearColor(0.2f, 0.1f, 0.8f, 0.1f);
135126
gl.glShadeModel(GL10.GL_SMOOTH);
136127
gl.glEnable(GL10.GL_DEPTH_TEST);
137128

AndroidViewDemo/src/com/oreilly/demo/android/pa/viewdemo/widget/TransformedViewWidget.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.graphics.Rect;
99
import android.graphics.drawable.Drawable;
1010
import android.view.View;
11+
import android.view.ViewGroup;
1112

1213

1314
/**
@@ -53,7 +54,7 @@ public TransformedViewWidget(
5354
@Override
5455
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
5556
setMeasuredDimension(
56-
getSuggestedMinimumWidth(),
57+
ViewGroup.LayoutParams.MATCH_PARENT,
5758
getSuggestedMinimumHeight());
5859
}
5960

0 commit comments

Comments
 (0)