Graphics Programs Reference
In-Depth Information
pixels (if you are on Eclipse, you can quick fix errors to import the class
android.widget.LinearLayout ).
2. Create two buttons for this layout and name them “Up” and “Down,” re-
spectively.
3. After setting width and height for the buttons using setWidth and
setHeight , set their layout parameters ( Listing 2-6 ).
Listing 2-6. ADDCONTENTVIEW/src/com/apress/android/ad-
dcontentview/Main.java
Button buttonUp = new Button(this);
buttonUp.setText("Up");
buttonUp.setWidth(110);
buttonUp.setHeight(85);
LinearLayout.LayoutParams
layoutParamsButtonUp = new
LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsButtonUp.setMargins(0, 0, 0, 20);
Button buttonDown = new Button(this);
buttonDown.setText("Down");
buttonDown.setWidth(110);
buttonDown.setHeight(85);
LinearLayout.LayoutParams
layoutParamsButtonDown = new
LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsButtonDown.setMargins(0, 20, 0,
0);
Note If using Eclipse, do not forget to quick fix the
errors.
 
 
Search WWH ::




Custom Search