SUMMARY
  継承するXML属性       
  android.view.Viewの属性を継承します。     
  android.view.ViewGroupの属性を継承します。        
  XML属性   
  属性      対応メソッド  概要      
  android:gravity setGravity(int) オブジェクトの配置方法を指定します。      
  android:ignoreGravity   setIgnoreGravity(int)   gravityで指定した配置方法の影響を受けないWidgetを指定します。    
  XML属性 
  オブジェクトの配置方法を指定します。
"|"で区切って複数指定することが可能です。
  "|"で区切って複数指定することが可能です。
指定値     デフォルト   動作      
  top             コンテナの上部に配置し、サイズ変更は行いません。        
  bottom          コンテナの下部に配置し、サイズ変更は行いません。        
  left            コンテナの左側に配置し、サイズ変更は行いません。        
  right           コンテナの右側に配置し、サイズ変更は行いません。        
  center_vertical         上下中央に配置し、サイズ変更は行いません。   
  fill_vertical           オブジェクトの高さを、コンテナのサイズに合わせます。      
  center_horizontal               左右中央に配置し、サイズ変更は行いません。   
  fill_horizontal         オブジェクトの幅を、コンテナのサイズに合わせます。       
  center          上下左右中央に配置し、サイズ変更は行いません。 
  fill    ○       オブジェクトの高さ・幅を、コンテナのサイズに合わせます。    
  clip_vertical           top/bottomの追加オプションとして、オブジェクトの上部/下部の境界をコンテナの境界に合わせます。    
  clip_horizontal         left/rightの追加オプションとして、オブジェクトの左側/右側の境界をコンテナの境界に合わせます。    
    _____  
    
    gravityで指定した配置方法の影響を受けないWidgetを指定します。
  - サンプルコード
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TestSample"
android:ignoreGravity="@+id/TEV"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/continue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
<TextView
android:id="@+id/TEV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff0000"
android:text="TextView"/>
</RelativeLayout>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TestSample"
android:ignoreGravity="@+id/TEV"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/continue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
<TextView
android:id="@+id/TEV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff0000"
android:text="TextView"/>
</RelativeLayout>
結果
     
 
  

0 件のコメント:
コメントを投稿