Graphics Programs Reference
In-Depth Information
surfaceView.setEGLContextClientVersion(2);
surfaceView.setRenderer(new
GLES20Renderer());
setContentView(_surfaceView);
2. Add the lines of code from Listing 2-8 after the setContentView
method to create a LinearLayout with LayoutParams lay-
outParamsUpDown and gravity bottom-left to keep the Lin-
earLayout away from the back button while in landscape mode (we
set screenOrientation to landscape later in this section). Quick
fix errors (if any) to import the required classes.
Listing
2-8. SLEEK
UI/src/com/apress/android/sleekui/
Main.java
LinearLayout layout = new LinearLayout(this);
LinearLayout.LayoutParams layoutParamsUpDown
= new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
layout.setGravity(Gravity.BOTTOM |
Gravity.LEFT);
3. To inflate XML-based views from a layout file, get access to the inflater
service by calling: getSystemSer-
vice(Context.LAYOUT_INFLATER_SERVICE);
4. Create a View object to reference the inflated view returned by the in-
flater.inflate method (as shown in Listing 2-9 ).
Listing
2-9. SLEEK
UI/src/com/apress/android/sleekui/
Main.java
LayoutInflater inflater = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View linearLayoutView = inflater
.inflate(R.layout.updown, layout, false);
5. After quick fixing the errors for unimported classes, rename the file
main.xml (inside res/layout folder) as updown.xml .
 
 
 
 
 
 
Search WWH ::




Custom Search