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 8178915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:52:53+00:00 2026-06-06T23:52:53+00:00

I am new to android. I created a main.xml file like <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent

  • 0

I am new to android. I created a main.xml file like

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:background="@android:color/white"
     android:paddingTop="5dp"
     android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"       
        android:layout_marginBottom="10dp"
        android:src="@drawable/mazarslogo" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/ic_launcher" />

    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        xmlns:android="http://schemas.android.com/apk/res/android" >

        ....

    </RelativeLayout>

 </LinearLayout>

This file is in my res/layout/main.xml folder. Now i create a new folder named layout-land and put a file main.xml in it. i.e. res/layout-land/main.xml, and put the following code in it

<?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/imageView1" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"       
        android:layout_marginBottom="10dp"
        android:src="@drawable/mazarslogo" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/ic_launcher" />

</LinearLayout>

here is my class

public class MainActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //---the two buttons are wired to the same event handler---
        Button btn_login = (Button)findViewById(R.id.btn_login );
        btn_login.setOnClickListener(btnListener);

         .....

    } //end of onCreate()

} //end of class MainActivity

But now when i run the project, the project open in portrait mode, but when i press ctrl+F11 to change the orientation of the emulator then i get error.

enter image description here

Here is the portrait mode pic

enter image description here

Why i am getting this error in landscape mode? What i am doing wrong?

Thanks

Edit
——————————————————————-

Here is my working res/layout-land/main.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:padding="1dip"
android:orientation="horizontal" > >

<LinearLayout
    android:orientation="vertical"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_gravity="center"
    android:paddingLeft="20dip"
    android:paddingRight="20dip" >

    <ImageView
        android:id="@+id/imageView1" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"       
        android:layout_marginBottom="10dp"
        android:src="@drawable/mazarslogo" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="10dp"
        android:src="@drawable/ic_launcher" />

    <TableLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:stretchColumns="*" >

        <TableRow>

            <Button
                android:id="@+id/btn_login"                 
                android:text="@string/login"                
                android:textSize="12sp" 
                android:textStyle="bold" />

            <Button
                android:id="@+id/btn_aboutUs"                           
                android:text="@string/aboutUs"                  
                android:textSize="12sp" 
                android:textStyle="bold" />

        </TableRow>

        <TableRow>
             <Button
                android:id="@+id/btn_contactUs"                 
                android:text="@string/contactUs"            
                android:textSize="12sp" 
                android:textStyle="bold" />

            <Button
                android:id="@+id/btn_exit"                  
                android:text="@string/exit"         
                android:textSize="12sp" 
                android:textStyle="bold" />
        </TableRow>
    </TableLayout>        
</LinearLayout>  

  • 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-06T23:52:55+00:00Added an answer on June 6, 2026 at 11:52 pm

    First thing keep in mind both xml should be with same data either imageview ,button,or layout there id should also be same for both layout for potrait and lancaspe layout and u have need to add following thing in menifest in activtiy

    android:configChanges="keyboardHidden|orientation"
    
    • 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
In My Application, My XML layout is like this: <RelativeLayout android:layout_width=fill_parent android:layout_height=fill_parent> <View class=com.project.twsbi.FingerPaint$MyView
I am new to android development. I have created a popup window which is
i have one doubt,i have created new project in eclipse with android 2.3.1 and
I'm pretty new to Android Development, i'm following some Youtube tutorials currently. I'd like
I created a push notifications app following this tutorial: http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html It works and when
I created a new MapActivity class MapProba . From main Activity I want to
In my Android application I create the layout programatically (ie an xml layout file
I am using the following code by the Android-people-XMLParsing example for parsing XML file
I want to display different images using gridview in android? Xml file: <?xml version=1.0

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.