Adjusting view when rotate 90 degree












0















I have created a layout and programmatically i want to rotate it by 90 degree. And rotation part is working fine but can't expand/resize the Width and height of that Layout according to the screen.



Here is my xml:



<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cardview_lay"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout

android:id="@+id/cardview_lay_vertical"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_gravity="center_vertical"
android:layout_margin="15dp"
android:background="@drawable/virtualcard_bg"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/card_details_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/world_map_image"
android:padding="@dimen/activity_horizontal_margin">

<RelativeLayout
android:id="@+id/lay1"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/qrCode"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/QrCode"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<ImageView
android:id="@+id/QrCode"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true" />
</RelativeLayout>


<TextView
android:id="@+id/txtCardName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lay1"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/txtPolicyNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtCardName"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/medilink_global"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtPolicyNumber"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/medilink_global"
android:layout_marginTop="@dimen/activity_horizontal_margin">

<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text="Member Since "
android:textAllCaps="true"
android:textColor="@color/black" />

<TextView
android:id="@+id/txtmemberSince"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/txt"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />


<ImageView
android:id="@+id/medilinkImg"
android:layout_width="82dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/image" />

</RelativeLayout>
</RelativeLayout>

</LinearLayout>




And button listener code for rotation in MainActivity is :



rotateIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rotateIsVisible) {
rotateIsVisible = false;
cardview_lay_vertical.animate().rotation(90).start();
} else {
cardview_lay_vertical.animate().rotation(0).start();
rotateIsVisible = true;
}
}
});


But the problem i'm facing is that i want to enlarge layout and all text according to the screen width and height while rotate.



Expecting result:
enter image description here










share|improve this question

























  • Since your card has a fixed height of "210dp", how can you expect it to "match_parent"? Fixed-sized elements are meant to be fixed, and not to scale.

    – Adinia
    Nov 13 '18 at 12:14


















0















I have created a layout and programmatically i want to rotate it by 90 degree. And rotation part is working fine but can't expand/resize the Width and height of that Layout according to the screen.



Here is my xml:



<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cardview_lay"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout

android:id="@+id/cardview_lay_vertical"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_gravity="center_vertical"
android:layout_margin="15dp"
android:background="@drawable/virtualcard_bg"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/card_details_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/world_map_image"
android:padding="@dimen/activity_horizontal_margin">

<RelativeLayout
android:id="@+id/lay1"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/qrCode"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/QrCode"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<ImageView
android:id="@+id/QrCode"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true" />
</RelativeLayout>


<TextView
android:id="@+id/txtCardName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lay1"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/txtPolicyNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtCardName"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/medilink_global"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtPolicyNumber"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/medilink_global"
android:layout_marginTop="@dimen/activity_horizontal_margin">

<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text="Member Since "
android:textAllCaps="true"
android:textColor="@color/black" />

<TextView
android:id="@+id/txtmemberSince"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/txt"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />


<ImageView
android:id="@+id/medilinkImg"
android:layout_width="82dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/image" />

</RelativeLayout>
</RelativeLayout>

</LinearLayout>




And button listener code for rotation in MainActivity is :



rotateIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rotateIsVisible) {
rotateIsVisible = false;
cardview_lay_vertical.animate().rotation(90).start();
} else {
cardview_lay_vertical.animate().rotation(0).start();
rotateIsVisible = true;
}
}
});


But the problem i'm facing is that i want to enlarge layout and all text according to the screen width and height while rotate.



Expecting result:
enter image description here










share|improve this question

























  • Since your card has a fixed height of "210dp", how can you expect it to "match_parent"? Fixed-sized elements are meant to be fixed, and not to scale.

    – Adinia
    Nov 13 '18 at 12:14
















0












0








0








I have created a layout and programmatically i want to rotate it by 90 degree. And rotation part is working fine but can't expand/resize the Width and height of that Layout according to the screen.



Here is my xml:



<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cardview_lay"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout

android:id="@+id/cardview_lay_vertical"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_gravity="center_vertical"
android:layout_margin="15dp"
android:background="@drawable/virtualcard_bg"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/card_details_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/world_map_image"
android:padding="@dimen/activity_horizontal_margin">

<RelativeLayout
android:id="@+id/lay1"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/qrCode"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/QrCode"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<ImageView
android:id="@+id/QrCode"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true" />
</RelativeLayout>


<TextView
android:id="@+id/txtCardName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lay1"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/txtPolicyNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtCardName"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/medilink_global"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtPolicyNumber"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/medilink_global"
android:layout_marginTop="@dimen/activity_horizontal_margin">

<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text="Member Since "
android:textAllCaps="true"
android:textColor="@color/black" />

<TextView
android:id="@+id/txtmemberSince"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/txt"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />


<ImageView
android:id="@+id/medilinkImg"
android:layout_width="82dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/image" />

</RelativeLayout>
</RelativeLayout>

</LinearLayout>




And button listener code for rotation in MainActivity is :



rotateIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rotateIsVisible) {
rotateIsVisible = false;
cardview_lay_vertical.animate().rotation(90).start();
} else {
cardview_lay_vertical.animate().rotation(0).start();
rotateIsVisible = true;
}
}
});


But the problem i'm facing is that i want to enlarge layout and all text according to the screen width and height while rotate.



Expecting result:
enter image description here










share|improve this question
















I have created a layout and programmatically i want to rotate it by 90 degree. And rotation part is working fine but can't expand/resize the Width and height of that Layout according to the screen.



Here is my xml:



<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cardview_lay"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout

android:id="@+id/cardview_lay_vertical"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_gravity="center_vertical"
android:layout_margin="15dp"
android:background="@drawable/virtualcard_bg"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/card_details_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/world_map_image"
android:padding="@dimen/activity_horizontal_margin">

<RelativeLayout
android:id="@+id/lay1"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/qrCode"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/QrCode"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<ImageView
android:id="@+id/QrCode"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true" />
</RelativeLayout>


<TextView
android:id="@+id/txtCardName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lay1"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/txtPolicyNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtCardName"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />

<TextView
android:id="@+id/medilink_global"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtPolicyNumber"
android:layout_marginTop="@dimen/activity_ten_margin"
android:gravity="center|left"
android:text=""
android:textAllCaps="true"
android:textColor="@color/black"
android:textStyle="bold" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/medilink_global"
android:layout_marginTop="@dimen/activity_horizontal_margin">

<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text="Member Since "
android:textAllCaps="true"
android:textColor="@color/black" />

<TextView
android:id="@+id/txtmemberSince"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/txt"
android:gravity="center|left"
android:paddingBottom="@dimen/activity_margin_four"
android:text=""
android:textColor="@color/black"
android:textStyle="bold" />


<ImageView
android:id="@+id/medilinkImg"
android:layout_width="82dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/image" />

</RelativeLayout>
</RelativeLayout>

</LinearLayout>




And button listener code for rotation in MainActivity is :



rotateIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rotateIsVisible) {
rotateIsVisible = false;
cardview_lay_vertical.animate().rotation(90).start();
} else {
cardview_lay_vertical.animate().rotation(0).start();
rotateIsVisible = true;
}
}
});


But the problem i'm facing is that i want to enlarge layout and all text according to the screen width and height while rotate.



Expecting result:
enter image description here







android rotation android-animation android-framelayout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 13:13









Fantômas

32.4k156388




32.4k156388










asked Nov 13 '18 at 11:30









pb123pb123

162317




162317













  • Since your card has a fixed height of "210dp", how can you expect it to "match_parent"? Fixed-sized elements are meant to be fixed, and not to scale.

    – Adinia
    Nov 13 '18 at 12:14





















  • Since your card has a fixed height of "210dp", how can you expect it to "match_parent"? Fixed-sized elements are meant to be fixed, and not to scale.

    – Adinia
    Nov 13 '18 at 12:14



















Since your card has a fixed height of "210dp", how can you expect it to "match_parent"? Fixed-sized elements are meant to be fixed, and not to scale.

– Adinia
Nov 13 '18 at 12:14







Since your card has a fixed height of "210dp", how can you expect it to "match_parent"? Fixed-sized elements are meant to be fixed, and not to scale.

– Adinia
Nov 13 '18 at 12:14














1 Answer
1






active

oldest

votes


















0














I usually create second layout to have screen orientation provided, it may be the best way to handle it.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280074%2fadjusting-view-when-rotate-90-degree%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I usually create second layout to have screen orientation provided, it may be the best way to handle it.






    share|improve this answer




























      0














      I usually create second layout to have screen orientation provided, it may be the best way to handle it.






      share|improve this answer


























        0












        0








        0







        I usually create second layout to have screen orientation provided, it may be the best way to handle it.






        share|improve this answer













        I usually create second layout to have screen orientation provided, it may be the best way to handle it.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 12:07









        SkypeDoggSkypeDogg

        7310




        7310






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280074%2fadjusting-view-when-rotate-90-degree%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine