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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:01:04+00:00 2026-05-24T23:01:04+00:00

I have an activity in android which I set up a button under a

  • 0

I have an activity in android which I set up a button under a SurfaceView. And the result looks like this:

And I’m satisfied with it except one thing, the writing on the button is astray and must be setup correctly.
For this I used animations like this:

takePhoto = (Button) findViewById(R.id.btnPhoto);
takePhoto.setText(t);

RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.myanim);
ranim.setFillAfter(true);
takePhoto.setAnimation(ranim);

WHERE the res/anim/myanim looks like:

<?xml version="1.0" encoding="utf-8"?>
<rotate  xmlns:android="http://schemas.android.com/apk/res/android"
       android:fromDegrees="0" 
       android:toDegrees="-90"
       android:pivotX="50%"
       android:pivotY="50%"
       android:duration="0" />

But the result is a little bit disappointing cause the whole looks like:

enter image description here

The text is ok, but the dimensions are reduced.

What I want is to keep the text correctly and the initial size.How could I do that???
It has nothing to do with the button’s properties in the xml file cause I haven’t changed them when loading the animation….Ideas?Thanks…

EDIT: xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
>

<SurfaceView android:layout_width="450dip"
android:layout_height="fill_parent" android:id="@+id/surface_camera" />

<RelativeLayout android:layout_width="fill_parent"
android:layout_toRightOf="@id/surface_camera"
android:layout_height="fill_parent"
 >

<Button android:layout_width="680dip"
android:layout_height="680dip" 
android:id="@+id/btnPhoto"
android:layout_alignParentBottom="true"
android:text="Take Photo" 
android:layout_gravity="bottom|right" />

</RelativeLayout>

</RelativeLayout>





IMPORTANT:

In the cases described below...my activity is in `LANDSCAPE` mode and the position of the phone is portrait.Another issue is that when I turn my phone in landscape mode(and here I mean the position of the phone, cause the activity is still landscape) the button doesn't go at the bottom of the phone is stays there.No matter how I turn the phone the button is in the same position!!!!
  • 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-24T23:01:05+00:00Added an answer on May 24, 2026 at 11:01 pm

    You should read this

    Make two layout folders like follows …

    enter image description here

    In both of folders your layout file name should be same.

    In layout-port folder your layout file should look like this …

    android:layout_toRightOf="@id/surface_camera"
    

    replaced by …

    android:layout_Below="@id/surface_camera"
    

    as follows …

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
    >
    
    <SurfaceView android:layout_width="450dip"
    android:layout_height="fill_parent" android:id="@+id/surface_camera" />
    
    <RelativeLayout android:layout_width="fill_parent"
    android:layout_toBelow="@id/surface_camera" 
    android:layout_height="fill_parent"
     >
    
    <Button android:layout_width="680dip"
    android:layout_height="680dip" 
    android:id="@+id/btnPhoto"
    android:layout_alignParentBottom="true"
    android:text="Take Photo" 
    android:layout_gravity="bottom|right" />
    
    </RelativeLayout>
    
    </RelativeLayout>
    

    Even this will considered as bad practice but you can also handle this manually, try this ..

        @Override
        public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           //setContentView(R.layout.main);
    
          int orientation = getResources().getConfiguration().orientation;
    
          if(orientation == Configuration.ORIENTATION_PORTRAIT) {
             setContentView(R.layout.main1);
    
          }
          else {
    
             setContentView(R.layout.main2);
          }
       }
    

    Also If you are doing this way No need to make two layout folders, but needs two layout files main1 and main2 in same folder

    Yet another option …

    In manifest …

    <activity android:name=".ActivityName" android:configChanges="keyboardHidden|orientation">
    

    +

    In your Activity …

     @Override
        public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
    
          int orientation = newConfig.orientation;
          if(orientation == Configuration.ORIENTATION_PORTRAIT) {
    
            setContentView(R.layout.main2);
          }
          else {
    
            setContentView(R.layout.main);
          }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a simple android app which have a edittext and a button.
I have an activity which is set up in the LANDSCAPE mode becuase there
I have an activity which is set up in the landscape mode and must
I have the following issue. In an activity which is set up in LANDSCAPE
I am writing an Android app in which I have a Map activity where
I have android app in which one layout contains Linearlayout , ScrollView , TextView
My manifest setup: targetSdkVersion=11 I have Activity with theme set to android:style/Theme.Holo.NoActionBar or android:style/Theme.NoTitleBar
I have Activity A with android:launchMode=singleTop in the manifest. If I go to Activity
I have an Activity in Android, with two elements: EditText ListView When my Activity
So I have a very simple android activity that starts a timer when you

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.