| RelativeLayout() | ใช้สร้าง Object RelativeLayout |
|---|---|
| getBaseline() | ใช้คืนค่า ตำแหน่ง แกน x ที่เป็น baseline ของ Object RelativeLayout |
| setGravity() | ใช้กำหนด การวางตำแหน่ง ให้กับ Object RelativeLayout |
| setHorizontalGravity() | ใช้กำหนด การวางตำแหน่ง ในแนวนอน ให้กับ Object RelativeLayout |
| setVerticalGravity() | ใช้กำหนด การวางตำแหน่ง ในแนวตั้ง ให้กับ Object RelativeLayout |
| ABOVE | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่เหนือ child อื่น |
| ALIGN_BASELINE | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ baseline อยู่ในระดับเดียวกับ baseline ของ child อื่น |
| ALIGN_BOTTOM | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบล่าง อยู่ในระดับเดียวกับ เส้นขอบล่าง ของ child อื่น |
| ALIGN_LEFT | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านซ้าย อยู่ในระดับเดียวกับ เส้นขอบด้านซ้าย ของ child อื่น |
| ALIGN_PARENT_BOTTOM | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านล่าง อยู่ในระดับเดียวกับ เส้นขอบด้านล่าง ของ relative layout |
| ALIGN_PARENT_LEFT | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านซ้าย อยู่ในระดับเดียวกับ เส้นขอบด้านซ้าย ของ relative layout |
| ALIGN_PARENT_RIGHT | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านขวา อยู่ในระดับเดียวกับ เส้นขอบด้านขวา ของ relative layout |
| ALIGN_PARENT_TOP | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านบน อยู่ในระดับเดียวกับ เส้นขอบด้านบน ของ relative layout |
| ALIGN_RIGHT | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านขวา อยู่ในระดับเดียวกับ เส้นขอบด้านขวา ของ child อื่น |
| ALIGN_TOP | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านบน อยู่ในระดับเดียวกับ เส้นขอบด้านบน ของ child อื่น |
| BELOW | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ใต้ child อื่น |
| CENTER_HORIZONTAL | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ตรงกลางเมื่อเทียบจากแนวนอน |
| CENTER_IN_PARENT | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ตรงกลางเมื่อเทียบจาก RelativeLayout |
| CENTER_VERTICAL | เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ตรงกลางเมื่อเทียบจากแนวตั้ง |
method:RelativeLayout ( Context context )
return type:RelativeLayout
content:ใช้สร้าง Object RelativeLayout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout relative_layout = new RelativeLayout ( this ); setContentView( relative_layout ); } }
method:getBaseline ( )
return type:int
content:ใช้คืนค่า ตำแหน่ง แกน x ที่เป็น baseline ของ Object RelativeLayout ( baseline คือ ด้านล่าง )
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout relative_layout = new RelativeLayout ( this ); int baseline = relative_layout.getBaseline ( ); setContentView( relative_layout ); } }
method:setGravity ( int gravity )
return type:void
content:ใช้กำหนด การวางตำแหน่ง ให้กับ Object RelativeLayout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout relative_layout = new RelativeLayout ( this ); relative_layout.setGravity ( Gravity.CENTER ); setContentView( relative_layout ); } }
method:setHorizontalGravity ( int horizontalGravity )
return type:void
content:ใช้กำหนด การวางตำแหน่ง ในแนวนอน ให้กับ Object RelativeLayout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout relative_layout = new RelativeLayout ( this ); relative_layout.setHorizontalGravity ( Gravity.CENTER_HORIZONTAL ); setContentView( relative_layout ); } }
method:setVerticalGravity ( int verticalGravity )
return type:void
content:ใช้กำหนด การวางตำแหน่ง ในแนวตั้ง ให้กับ Object RelativeLayout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout relative_layout = new RelativeLayout ( this ); relative_layout.setVerticalGravity ( Gravity.CENTER_VERTICAL ); setContentView( relative_layout ); } }
property:ABOVE
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่เหนือ child อื่น
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ABOVE ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "below" ); Button button_2 = new Button ( this ); button_2.setText ( "above" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_BASELINE
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ baseline อยู่ในระดับเดียวกับ baseline ของ child อื่น
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_BASELINE ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_BOTTOM
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบล่าง อยู่ในระดับเดียวกับ เส้นขอบล่าง ของ child อื่น
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_BOTTOM ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_LEFT
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านซ้าย อยู่ในระดับเดียวกับ เส้นขอบด้านซ้าย ของ child อื่น
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_LEFT ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_PARENT_BOTTOM
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านล่าง อยู่ในระดับเดียวกับ เส้นขอบด้านล่าง ของ relative layout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_PARENT_BOTTOM ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_PARENT_LEFT
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านซ้าย อยู่ในระดับเดียวกับ เส้นขอบด้านซ้าย ของ relative layout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_PARENT_LEFT ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_PARENT_RIGHT
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านขวา อยู่ในระดับเดียวกับ เส้นขอบด้านขวา ของ relative layout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_PARENT_RIGHT ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_PARENT_TOP
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านบน อยู่ในระดับเดียวกับ เส้นขอบด้านบน ของ relative layout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_PARENT_TOP ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_RIGHT
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านขวา อยู่ในระดับเดียวกับ เส้นขอบด้านขวา ของ child อื่น
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_RIGHT ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:ALIGN_TOP
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า ให้ เส้นขอบด้านบน อยู่ในระดับเดียวกับ เส้นขอบด้านบน ของ child อื่น
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.ALIGN_TOP ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "main" ); Button button_2 = new Button ( this ); button_2.setText ( "compare" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:BELOW
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ใต้ child อื่น
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.BELOW ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "below" ); Button button_2 = new Button ( this ); button_2.setText ( "above" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:CENTER_HORIZONTAL
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ตรงกลางเมื่อเทียบจากแนวนอน
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.CENTER_HORIZONTAL ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "below" ); Button button_2 = new Button ( this ); button_2.setText ( "above" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:CENTER_IN_PARENT
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ตรงกลางเมื่อเทียบจาก RelativeLayout
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.CENTER_IN_PARENT ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "below" ); Button button_2 = new Button ( this ); button_2.setText ( "above" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }
property:CENTER_VERTICAL
return type:int
content:เป็นค่าคงที่ ของ RelativeLayout ที่ใช้แทนความหมายว่า อยู่ตรงกลางเมื่อเทียบจากแนวตั้ง
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( 100, 30 ); params.addRule ( RelativeLayout.CENTER_VERTICAL ); RelativeLayout relative_layout = new RelativeLayout ( this ); Button button_1 = new Button ( this ); button_1.setText ( "below" ); Button button_2 = new Button ( this ); button_2.setText ( "above" ); button_2.setLayoutParams ( params ); relative_layout.addView ( button_1 ); relative_layout.addView ( button_2 ); setContentView( relative_layout ); } }