2011-08-01 5 views
0

주 화면에 여러 개의 ARViews이 카메라 미리보기 위에 표시되는 Augmented Reality 앱을 사용하고 있습니다. 이 ARViews는 TextViews가있는 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

하면 전체 폭과 높이를 포함한다 모든 뷰에 포함되는 뷰 그룹을 만들 shuld. 이제 뷰 그룹에 사용자 지정 드로잉을 배경으로 사용해야하는 다른 뷰를 추가 할 수 있습니다. 새로운 상대 레이아웃을 만들고 거기에있는 모든 추가 항목을 만들 수도 있습니다.