0

我有一个自定义视图,其中有一个用圆圈和线条绘制的画布。我的问题是,一旦转移到平板电脑看起来裁剪图像而不是真实的。有没有办法调整 CustomView 的大小并自动适应屏幕,甚至滚动图像。一点代码:

public class CustomView extends View {

    Paint pPaint;
    Paint cPaint;
    Paint textPaint;

    int w,h;
    int px=150,py=150;
    int cx=450,cy=150;
    public CustomView(Context context, AttributeSet attrs) {
        super(context, attrs);


        pPaint=new Paint(); // pennello
        pPaint.setColor(Color.RED);  
        pPaint.setAntiAlias(true); 

        cPaint=new Paint(); // pennello
        cPaint.setColor(Color.CYAN);     
        cPaint.setAntiAlias(true);

        textPaint=new Paint(); // pennello
        textPaint.setColor(Color.BLACK);     
        textPaint.setAntiAlias(true);

    }



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <com.abstractargument.CustomView
            android:id="@+id/customView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>

</RelativeLayout>
4

0 回答 0