
我的 XML:
<LinearLayout 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:orientation="horizontal"
    android:weightSum="1" >
    <LinearLayout
        android:id="@+id/leftLayout"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight=".5"
        android:orientation="vertical"
        android:weightSum="1" >
        <LinearLayout
            android:id="@+id/firstProblem"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".5"
            android:weightSum="1" >
            <com.student.spelling.SpellViewFirst
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="3dp"
            android:background="@android:color/black" />
        <LinearLayout
            android:id="@+id/secondProblem"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".5"
            android:weightSum="1" >
             <com.student.spelling.SpellViewFirst
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>
    </LinearLayout>
    <View
        android:layout_width="3dp"
        android:layout_height="fill_parent"
        android:background="@android:color/black" />
    <LinearLayout
        android:id="@+id/rightLayout"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight=".5"
        android:orientation="vertical"
        android:weightSum="1" >
        <LinearLayout
            android:id="@+id/thirdProblem"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".5"
            android:weightSum="1" >
               <com.student.spelling.SpellViewFirst
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="3dp"
            android:background="@android:color/black" />
        <LinearLayout
            android:id="@+id/fourthProblem"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".5"
            android:weightSum="1" >
              <com.student.spelling.SpellViewFirst
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
我的视图类:
public class SpellViewFirst extends View {
    private StartActivity studentActivity;
    private int screenWidth;
    private int screenHeight;
    private Bitmap imageBitmap;
    private ArrayList<Character> charList;
    List<SpellObjects> spellObjectsList;
    private String word;
    int placeHolderHeight;
    private ArrayList<Integer> dragable_id_object_list;
    private Bitmap placeHolderBitmap; 
    Point placeHolderPoints;
    Point alphabetPoints;
    private int indexOfCurrentObject;
    private int offsetX;
    private int offsetY;
    public SpellViewFirst(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
        studentActivity = (StartActivity)context;
    }
    @Override
    protected void onSizeChanged(int width, int height, int oldwidth, int oldheight) {
        // TODO Auto-generated method stub
        super.onSizeChanged(width, height, oldwidth, oldheight);
        screenWidth = width;
        screenHeight = height;
        assignCoordinatesToImages();
    }
    private void assignCoordinatesToImages() {
        // TODO Auto-generated method stub
        Bitmap bm=BitmapFactory.decodeFile("/mnt/sdcard/resources/images/spelling/ques.png");
        dragable_id_object_list=new ArrayList<Integer>() ;
        spellObjectsList=new ArrayList<SpellObjects>();
        SpellObjects curentObjects;
        placeHolderHeight=bm.getHeight();
        word=studentActivity.correctWordsArray[0];
        imageBitmap=BitmapFactory.decodeFile("/mnt/sdcard/resources/images/spelling/"+word+".png");
        placeHolderBitmap=Bitmap.createScaledBitmap(bm, screenWidth/word.length(), screenWidth/word.length(),true);
        charList=new ArrayList<Character>();
        placeHolderPoints=new Point();
        for (int i = 0; i < word.length(); i++) {
            charList.add(word.charAt(i));
        }
        for (int i = 0; i < charList.size(); i++) {
            placeHolderPoints.y=screenHeight/2;     
            curentObjects=new SpellObjects(placeHolderPoints, placeHolderBitmap, -1,charList.get(i), null, placeHolderBitmap.getHeight(), screenWidth/word.length(), true);
            placeHolderPoints.x=placeHolderPoints.x+screenWidth/word.length();
            spellObjectsList.add(curentObjects);
        }
        Collections.shuffle(charList);
        alphabetPoints=new Point();
        alphabetPoints.x=imageBitmap.getWidth();
        for (int i = 0; i < charList.size(); i++) {
            Bitmap bitmap= BitmapFactory.decodeFile("/mnt/sdcard/resources/images/spelling/"+charList.get(i)+".png");
            curentObjects=new SpellObjects(alphabetPoints,bitmap, i,charList.get(i), null, placeHolderBitmap.getHeight(), screenWidth/word.length(), true);
            alphabetPoints.x=alphabetPoints.x+bitmap.getWidth();
            spellObjectsList.add(curentObjects);
            dragable_id_object_list.add(i, i);
        }
    }
    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        canvas.drawBitmap(imageBitmap, 0, 0, null);
        for(SpellObjects currentObjects :spellObjectsList ){
            if(currentObjects.getIsCorrectlyPlaced())
                canvas.drawBitmap(currentObjects.getobjectBitmap(), currentObjects.getCurrentPoint().x,currentObjects.getCurrentPoint().y, null);
        }
    }
}
我想在其他三个象限中渲染像蛋糕、鸭子和好的东西。实际上,这是为孩子们设计的拼写应用程序,他们可以将字母拖放到各自的位置。请帮帮我,我被卡住了。