2012-02-16 19 views
0
public class DrawView extends View implements OnTouchListener { 
    private static final String TAG = "DrawView"; 

    List<Point> points = new ArrayList<Point>(); 
    Paint paint = new Paint(); 

    public DrawView(Context context) { 
     super(context);....... 

* 私はこのクラスは描画行のために長いコードがあり、これは動作していますが、それは黒、青または他の無地の色で作業しています私はそれを私のレイアウト*自分のレイアウトに線を描画するにはどうすればよいですか?

public class matchFun extends Activity { 
DrawView drawView; 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 


     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); 

     requestWindowFeature(Window.FEATURE_NO_TITLE); 

     drawView = new DrawView(this); 
     // setContentView(R.layout.matchfun); 
     // setContentView(drawView); 
     drawView.setBackgroundResource(R.layout.matchfun); 
     drawView.requestFocus();.... 

* これは私が第二のクラスで線を描画したい上位1を継承しているクラスがある*

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/widget0" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/back_lightblue" 
    > 

<ImageView 
    android:id="@+id/widget32" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="4dp" 
    android:layout_y="118dp" 
    android:src="@drawable/ic_launcher" 
    android:onClick="buttonClickHandler" 
    android:clickable="true"/> 

<ImageView 
    android:id="@+id/widget33" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="7dp" 
    android:layout_y="196dp" 
    android:src="@drawable/ic_launcher" 
    android:onClick="buttonClickHandler" 
    android:clickable="true"/> 

これは私のXMLです。何か考えてくださいこの問題を解決してください私は最後のカップルからそれに取り組んで何も解決策を見つけることができませんでした

+0

1日前に似たような質問をしました:http://stackoverflow.com/questions/9296712/android-how-to-draw-a-simple-line-and-display-it-in-a-widgetあなたは検索について知っていますか? – Silver

答えて

1

キャンバスを使用する必要があります。また、キャンバスビューを透明にするだけでイメージに描画したい場合は、あなたがそれを使用しているとき、あなたがそれに取り組んでいるようです。

私はうまくいくと思います。詳細については、 Android Draw canvasをご覧ください。

+0

問題を解決しましたか? –

関連する問題