2011-08-01 11 views
0

私はAugmented Realityアプリをやっています。メイン画面には、カメラプレビューに表示された ARViewsがいくつか含まれています。これらのARViewはTextViewを内部で拡張したLinearLayoutです。 これらのビューは、画面上の異なる垂直位置に描画されます。今度は、スクリーンショットのように、各ビューの中央から画面の中央に垂直線を描きたいと思います。もちろんLinearLayoutに可変長線を描く

enter image description here

ビューは、行の長さが変化するように、ユーザは、デバイスを移動したときに移動します。

これをARViewに追加するにはどうすればよいですか?

public class ARView extends LinearLayout 
{  
    public float azimuth = 0;   
    public float inclination = 0; 
    public Location location; 
    public int position; 

    TextView title, type, distance; 

    public int X, Y; 

    public ARView(final Context context, int ind) 
    {   
     super(context); 
     getLayoutInflater().inflate(R.layout.ar_item, this ,true); 
     LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     inflater.inflate(R.layout.ar_item, null); 

     title = (TextView) findViewById(R.id.title); 
     type = (TextView) findViewById(R.id.type); 
     distance = (TextView) findViewById(R.id.distance); 
    } 
} 

ar_item.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ar_item" android:layout_width="202dp" 
    android:layout_height="62dp" android:background="@drawable/bg_item_ar" 
    android:clickable="true"> 

    <LinearLayout android:id="@+id/container" 
     android:orientation="vertical" android:layout_width="164dp" 
     android:layout_height="fill_parent" android:paddingBottom="5dp" 
     android:paddingLeft="8dp" android:paddingTop="5dp" 
     android:paddingRight="6dp" android:clickable="true"> 

     <TextView android:id="@+id/title" android:layout_width="fill_parent" 
      android:layout_height="18dp" android:textSize="13sp" 
      android:textColor="#FFFFFF" android:textStyle="bold"/> 

     <TextView android:id="@+id/type" android:layout_width="fill_parent" 
      android:layout_height="18dp" android:textSize="13sp" 
      android:textColor="#FFFFFF"/> 

     <TextView android:id="@+id/distance" 
      android:layout_width="fill_parent" android:layout_height="16dp" 
      android:textSize="12sp" android:textColor="#C6C6C6" /> 

    </LinearLayout> 

</LinearLayout> 

答えて

0

あなたが全体の幅と高さをカバーする必要があり、これらすべてのビューが含まれているのViewGroupを作成shuld。これで、カスタム図面で背景として機能する別のビューをビューグループに追加できます。あなたはまた、新しい相対的なレイアウトを作成することができますし、そこにすべての余分なもの。