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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:14:44+00:00 2026-05-27T23:14:44+00:00

I’m new to android development(v 4.0, API 14) and stuck in implementing orientation change.

  • 0

I’m new to android development(v 4.0, API 14) and stuck in implementing orientation change.

I’ve added the following line in manifest file
android:configChanges="orientation|keyboardHidden|screenSize">

But it looks like screenSize parameter is not working so I have to manually write these two methods:

public void ChangetoLandscape() {
    ed.setTranslationX(300.0f);
    btnindex.setTranslationX(300.0f);
    btngainer.setTranslationX(300.0f);
    btnloser.setTranslationX(300.0f);
    lsym.setTranslationX(200.0f);
    ltable.setTranslationX(300.0f);
    tv1.setTranslationX(290.0f);
    tv2.setTranslationX(300.0f);
    tv4.setTranslationX(300.0f);

    mySimpleXYPlot.setScaleX(3.0f);
    mySimpleXYPlot.setScaleY(0.8f);
    mySimpleXYPlot.setPlotMarginLeft(50.0f);
    mySimpleXYPlot.setTranslationX(60.0f);
    mySimpleXYPlot.setTranslationY(-70.0f);

    sv1.setTranslationY(-80.0f);
}

public void ChangetoPortrait() {

//NOTE THAT IF I DON'T WRITE BELOW CODE,
//SWITCHING TO PORTRAIT MODE AFTER LANDSCAPE MODE RUINS THE WHOLE LAYOUT.
        ed.setTranslationX(-1.0f);
        btnindex.setTranslationX(-1.0f);
        btngainer.setTranslationX(-1.0f);
        btnloser.setTranslationX(-1.0f);
        lsym.setTranslationX(-1.0f);
        ltable.setTranslationX(-1.0f);
        tv1.setTranslationX(-1.0f);
        tv2.setTranslationX(-1.0f);
        tv4.setTranslationX(-1.0f);
        mySimpleXYPlot.setScaleX(1.0f);
        mySimpleXYPlot.setScaleY(1.0f);
        mySimpleXYPlot.setPlotMarginLeft(1.0f);
        mySimpleXYPlot.setTranslationX(-1.0f);
        mySimpleXYPlot.setTranslationY(-1.0f);

        sv1.setTranslationY(-1.0f);
}

.

I’m using RelativeLayout, so I’ve to manually translate each view to specified position on orientation change.

main.xml

<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical"
android:id="@+id/MainLayout">"
<EditText
    android:id="@+id/txt1"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:hint="Search"
    android:layout_marginLeft="220dp"
    android:selectAllOnFocus="true"
    android:cursorVisible="false" >
</EditText>

<Button
    android:id="@+id/btnindex"
    android:layout_width="60dp"
    android:layout_height="wrap_content"
    android:text="Index" 
    android:layout_marginLeft="140dp"
    android:layout_below="@id/txt1"
    android:textSize="12dp"/>

<Button
    android:id="@+id/btngainer"
    android:layout_width="60dp"
    android:layout_height="wrap_content"
    android:text="Gainer" 
    android:layout_below="@id/txt1"
    android:layout_toRightOf="@id/btnindex"
    android:textSize="12dp"/>

<Button
    android:id="@+id/btnloser"
    android:layout_width="60dp"
    android:layout_height="wrap_content"
    android:text="Loser" 
    android:layout_below="@id/txt1"
    android:layout_toRightOf="@id/btngainer"
    android:textSize="12dp"/>

<TextView
    android:id="@+id/tv1"
    android:layout_width="75dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="150dp"
    android:layout_marginTop="100dp"
    android:textStyle="bold"
    android:gravity="center"
    android:textSize="10dp"
    android:textColor="#00ff00"
    android:text="SYMBOL"/> <!-- 2 similar textviews -->

<ListView
        android:id="@+id/ltable"
        android:layout_height="wrap_content"
        android:layout_marginLeft="150dp"
        android:layout_marginTop="70dp"
        android:layout_alignParentRight="true"
        android:layout_width="match_parent"
        android:layout_below="@id/txt1">
</ListView>
    
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
android:layout_width="140dp"
android:layout_height="200dp"
android:layout_alignTop="@+id/btnindex"
title="Index"/>

<ScrollView android:id="@+id/sv1"
android:layout_width="300dp"
android:layout_height="100dp"
android:layout_marginTop="250dp">

<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:orientation="vertical">

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv1"
android:text="Scrollview Item 1"/> <!-- 5 similar textviews -->
</LinearLayout>
</ScrollView>

</RelativeLayout>

.

  1. But as showed in below screenshot, in landscape mode, graph which is plotted using android plot is not getting properly displayed. The reason behind this is I’ve used setScaleX() method bcoz setWidth() is not available. I don’t want graph to look stretched. Instead it’s width should be increased.

  2. ScrollView is getting displayed properly in portrait mode but in landscape mode, it is not visivle according to it’s height which is 100dp.

ScreenShot


Edit: After changing android:configChanges="orientation|keyboardHidden|screenSize" to
android:configChanges="orientation|screenSize",
I get this when I switch to landscape mode:

ScreenShot

  • 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-05-27T23:14:45+00:00Added an answer on May 27, 2026 at 11:14 pm

    use LayoutParams to place the graph at appropriate location instead of scale() function.

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
I have a reasonable size flat file database of text documents mostly saved in

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.