Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:58:21+00:00 2026-06-11T14:58:21+00:00

My 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

  • 0

enter image description here

My 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>

My View Class :

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);
        }
    }
}

I want to render like cake,duck and good in other three quadrants.Actually this is spelling app for kids where they can drag and drop alphabets to respective positions.Please help me out I am stuck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:58:22+00:00Added an answer on June 11, 2026 at 2:58 pm

    I want to render like cake,duck and good in other three quadrants.

    To set different images for your custom View you’ll need to add a custom attribute for your custom layout to signal the desired image(or an id, or something to uniquely identify the view). Something like this(in attr.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <declare-styleable name="CustomAttr">
            <attr name="pictureName" format="string" />
        </declare-styleable>
    </resources>
    

    This attribute will be used in the layout like this:

    <com.student.spelling.SpellViewFirst
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" 
                    newtag:pictureName="one_of_your_picture_names_here"/>
    

    Don’t forget to set the newtag namespace in the root of your xml layout:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:newtag="http://schemas.android.com/apk/res/your.package.here"
    // ...
    

    Then you’ll use that attribute to make the SpellViewFirst use the targeted image:

    public SpellViewFirst(Context context, AttributeSet attrs) {
            super(context, attrs);     
            studentActivity = (StartActivity)context;
            if (attrs != null) {
                    TypedArray ta = context.obtainStyledAttributes(attrs,
                            R.styleable.CustomAttr, 0, 0);
                    word = ta.getString();// this is what you use to get the picture name, right?
                    ta.recycle();
            }
    }
    

    Then you could use the word variable to get the desired Bitmap in assignCoordinatesToImages(). Don’t forget to test word for null(meaning a picture name wasn’t set in the layout) and show a default image instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my XML file <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=wrap_content android:layout_height=wrap_content android:orientation=vertical android:id=@+id/sl > <RadioGroup android:layout_width=wrap_content android:layout_height=wrap_content android:orientation=vertical
Below is my layout xml file: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:tools=http://schemas.android.com/tools android:id=@+id/LinearLayout1 android:layout_width=match_parent android:layout_height=match_parent android:orientation=horizontal >
<?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent > I get these two errors
<?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical > <ImageView android:id=@+id/venueImage android:layout_width=wrap_content android:layout_height=wrap_content/> </LinearLayout>
main.xml <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/root android:layout_width=match_parent android:layout_height=wrap_content android:orientation=vertical > <LinearLayout android:id=@+id/horizontal android:layout_width=fill_parent
I've this xml: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical > <ImageView android:src=@drawable/head
Here is my layout <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:id=@+id/LinearLayout01 android:layout_height=wrap_content> <Spinner android:text=@+id/AutoCompleteTextView01
I've got the following layout XML file: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/main_layout android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical> <GridView
I use TableLayout with android. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent> <TableLayout
This is my code: <?xml version=1.0 encoding=utf-8?> 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 <EditText

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.