【问题标题】:How can i draw a line on my own layout?如何在我自己的布局上画一条线?
【发布时间】:2012-02-17 03:14:09
【问题描述】:
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();....

*这是继承上一个的类,我想在第二类中画线*

<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 请建议我任何想法,请解决这个问题,我从过去几周开始一直在努力解决这个问题,但仍然找不到任何解决方案

【问题讨论】:

标签: android layout


【解决方案1】:

要在任何布局上绘制一条线,您必须使用 Canvas。如果您想在图像上绘图,只需使画布视图透明即可。当你在使用它时,就好像你在努力。

我认为它会起作用。如果您想了解更多信息,请参阅 Android Draw canvas .

【讨论】:

    猜你喜欢
    • 2013-01-14
    • 1970-01-01
    • 2013-09-21
    • 2017-04-02
    • 2012-05-30
    • 2018-01-29
    • 2014-07-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多