Graphics Programs Reference
In-Depth Information
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View linearLayoutView = inflater
.inflate(R.layout.updown, rl, false);
View buttonView = inflater
.inflate(R.layout.missile, rl, false);
rl.addView(linearLayoutView);
rl.addView(buttonView);
addContentView(rl, rllp);
setUpDownClickListeners();
getDeviceWidth();
First, we set the layout's gravity to Gravity.BOTTOM . This will align the nested
elements with its bottom. Then, after inflating the views they are added to the layout.
Finally, by calling the addContentView() method, the entire layout is added as
an additional content view - as shown in Figure 6-1 .
Figure 6-1 . Fire button
Because screen touch is used to rotate the tank, this application requires the device
width (you can refer back to the section - “Using Touch for Rotation” in Chapter 2
to re-examine this logic). It is obtained by accessing the display metrics members,
which are used in the getDeviceWidth() method, shown in Listing 6-5 .
 
 
 
Search WWH ::




Custom Search