How to scale the view to fit the content size in Android using animations










0















I have two views on parent Layout those are top and bottom screens and bottom screen having fixed height and its align to parent-bottom and top screen based on content it must be extend and collapse on parent Layout when i tapped on it and bottom screen automatically come down from top screen and i can able to scroll total content on parent Layout can some one help me please



activity_main.layout



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

<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_view"
android:background="#3143ff" />

<View
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary" />


</RelativeLayout>


MainActivity:



public class MainActivity extends AppCompatActivity 

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final View view = findViewById(R.id.view);
final View contentView = findViewById(R.id.content_frame);
view.setOnClickListener(v ->
final int screenHeight = contentView.getHeight();
ValueAnimator heightAnimator = ValueAnimator.ofInt(view.getHeight(), screenHeight);
heightAnimator.setDuration(1500);
heightAnimator.addUpdateListener(animation ->
view.getLayoutParams().height = (int) animation.getAnimatedValue();
view.requestLayout();
);
heightAnimator.start();
);











share|improve this question






















  • why not using wrap_content as layout_height for first view.it will expand and collapse according to data.

    – Ali Ahmed
    Nov 15 '18 at 5:38












  • its client requirement initially we are showing half details when i tapped on it must be extend based on content size with the help of animations

    – AbhiRam
    Nov 15 '18 at 5:43











  • Ohh Okay. You can use Folding Library easily found on Github

    – Ali Ahmed
    Nov 15 '18 at 5:44















0















I have two views on parent Layout those are top and bottom screens and bottom screen having fixed height and its align to parent-bottom and top screen based on content it must be extend and collapse on parent Layout when i tapped on it and bottom screen automatically come down from top screen and i can able to scroll total content on parent Layout can some one help me please



activity_main.layout



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

<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_view"
android:background="#3143ff" />

<View
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary" />


</RelativeLayout>


MainActivity:



public class MainActivity extends AppCompatActivity 

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final View view = findViewById(R.id.view);
final View contentView = findViewById(R.id.content_frame);
view.setOnClickListener(v ->
final int screenHeight = contentView.getHeight();
ValueAnimator heightAnimator = ValueAnimator.ofInt(view.getHeight(), screenHeight);
heightAnimator.setDuration(1500);
heightAnimator.addUpdateListener(animation ->
view.getLayoutParams().height = (int) animation.getAnimatedValue();
view.requestLayout();
);
heightAnimator.start();
);











share|improve this question






















  • why not using wrap_content as layout_height for first view.it will expand and collapse according to data.

    – Ali Ahmed
    Nov 15 '18 at 5:38












  • its client requirement initially we are showing half details when i tapped on it must be extend based on content size with the help of animations

    – AbhiRam
    Nov 15 '18 at 5:43











  • Ohh Okay. You can use Folding Library easily found on Github

    – Ali Ahmed
    Nov 15 '18 at 5:44













0












0








0








I have two views on parent Layout those are top and bottom screens and bottom screen having fixed height and its align to parent-bottom and top screen based on content it must be extend and collapse on parent Layout when i tapped on it and bottom screen automatically come down from top screen and i can able to scroll total content on parent Layout can some one help me please



activity_main.layout



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

<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_view"
android:background="#3143ff" />

<View
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary" />


</RelativeLayout>


MainActivity:



public class MainActivity extends AppCompatActivity 

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final View view = findViewById(R.id.view);
final View contentView = findViewById(R.id.content_frame);
view.setOnClickListener(v ->
final int screenHeight = contentView.getHeight();
ValueAnimator heightAnimator = ValueAnimator.ofInt(view.getHeight(), screenHeight);
heightAnimator.setDuration(1500);
heightAnimator.addUpdateListener(animation ->
view.getLayoutParams().height = (int) animation.getAnimatedValue();
view.requestLayout();
);
heightAnimator.start();
);











share|improve this question














I have two views on parent Layout those are top and bottom screens and bottom screen having fixed height and its align to parent-bottom and top screen based on content it must be extend and collapse on parent Layout when i tapped on it and bottom screen automatically come down from top screen and i can able to scroll total content on parent Layout can some one help me please



activity_main.layout



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

<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_view"
android:background="#3143ff" />

<View
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary" />


</RelativeLayout>


MainActivity:



public class MainActivity extends AppCompatActivity 

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final View view = findViewById(R.id.view);
final View contentView = findViewById(R.id.content_frame);
view.setOnClickListener(v ->
final int screenHeight = contentView.getHeight();
ValueAnimator heightAnimator = ValueAnimator.ofInt(view.getHeight(), screenHeight);
heightAnimator.setDuration(1500);
heightAnimator.addUpdateListener(animation ->
view.getLayoutParams().height = (int) animation.getAnimatedValue();
view.requestLayout();
);
heightAnimator.start();
);








android android-animation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 5:35









AbhiRamAbhiRam

63811443




63811443












  • why not using wrap_content as layout_height for first view.it will expand and collapse according to data.

    – Ali Ahmed
    Nov 15 '18 at 5:38












  • its client requirement initially we are showing half details when i tapped on it must be extend based on content size with the help of animations

    – AbhiRam
    Nov 15 '18 at 5:43











  • Ohh Okay. You can use Folding Library easily found on Github

    – Ali Ahmed
    Nov 15 '18 at 5:44

















  • why not using wrap_content as layout_height for first view.it will expand and collapse according to data.

    – Ali Ahmed
    Nov 15 '18 at 5:38












  • its client requirement initially we are showing half details when i tapped on it must be extend based on content size with the help of animations

    – AbhiRam
    Nov 15 '18 at 5:43











  • Ohh Okay. You can use Folding Library easily found on Github

    – Ali Ahmed
    Nov 15 '18 at 5:44
















why not using wrap_content as layout_height for first view.it will expand and collapse according to data.

– Ali Ahmed
Nov 15 '18 at 5:38






why not using wrap_content as layout_height for first view.it will expand and collapse according to data.

– Ali Ahmed
Nov 15 '18 at 5:38














its client requirement initially we are showing half details when i tapped on it must be extend based on content size with the help of animations

– AbhiRam
Nov 15 '18 at 5:43





its client requirement initially we are showing half details when i tapped on it must be extend based on content size with the help of animations

– AbhiRam
Nov 15 '18 at 5:43













Ohh Okay. You can use Folding Library easily found on Github

– Ali Ahmed
Nov 15 '18 at 5:44





Ohh Okay. You can use Folding Library easily found on Github

– Ali Ahmed
Nov 15 '18 at 5:44












1 Answer
1






active

oldest

votes


















0














See FoldingCell for Android for more help.



In your build.gradle()



dependencies
implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'



In you XML layout



<com.ramotion.foldingcell.FoldingCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/folding_cell"
android:layout_width="match_parent"
android:layout_height="wrap_content">


<!--Layout One--> ​

<!--Layout Two-->


</com.ramotion.foldingcell.FoldingCell>


Almost done! Two steps remain! For correct animation, you need to set up two properties on the root element(s) of your Folding Cell: ​




android:clipChildren="false"



android:clipToPadding="false"




In your Java class



 // get our folding cell
final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);

// attach click listener to folding cell
fc.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
fc.toggle(false);

);





share|improve this answer























  • android:clipChildren="false" android:clipToPadding="false" where should i keep this steps?

    – AbhiRam
    Nov 15 '18 at 6:04











  • set up two properties on the root element(s) means <com.ramotion.foldingcell.FoldingCell > inside here.,

    – Ali Ahmed
    Nov 15 '18 at 6:07











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%2f53313045%2fhow-to-scale-the-view-to-fit-the-content-size-in-android-using-animations%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














See FoldingCell for Android for more help.



In your build.gradle()



dependencies
implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'



In you XML layout



<com.ramotion.foldingcell.FoldingCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/folding_cell"
android:layout_width="match_parent"
android:layout_height="wrap_content">


<!--Layout One--> ​

<!--Layout Two-->


</com.ramotion.foldingcell.FoldingCell>


Almost done! Two steps remain! For correct animation, you need to set up two properties on the root element(s) of your Folding Cell: ​




android:clipChildren="false"



android:clipToPadding="false"




In your Java class



 // get our folding cell
final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);

// attach click listener to folding cell
fc.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
fc.toggle(false);

);





share|improve this answer























  • android:clipChildren="false" android:clipToPadding="false" where should i keep this steps?

    – AbhiRam
    Nov 15 '18 at 6:04











  • set up two properties on the root element(s) means <com.ramotion.foldingcell.FoldingCell > inside here.,

    – Ali Ahmed
    Nov 15 '18 at 6:07
















0














See FoldingCell for Android for more help.



In your build.gradle()



dependencies
implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'



In you XML layout



<com.ramotion.foldingcell.FoldingCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/folding_cell"
android:layout_width="match_parent"
android:layout_height="wrap_content">


<!--Layout One--> ​

<!--Layout Two-->


</com.ramotion.foldingcell.FoldingCell>


Almost done! Two steps remain! For correct animation, you need to set up two properties on the root element(s) of your Folding Cell: ​




android:clipChildren="false"



android:clipToPadding="false"




In your Java class



 // get our folding cell
final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);

// attach click listener to folding cell
fc.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
fc.toggle(false);

);





share|improve this answer























  • android:clipChildren="false" android:clipToPadding="false" where should i keep this steps?

    – AbhiRam
    Nov 15 '18 at 6:04











  • set up two properties on the root element(s) means <com.ramotion.foldingcell.FoldingCell > inside here.,

    – Ali Ahmed
    Nov 15 '18 at 6:07














0












0








0







See FoldingCell for Android for more help.



In your build.gradle()



dependencies
implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'



In you XML layout



<com.ramotion.foldingcell.FoldingCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/folding_cell"
android:layout_width="match_parent"
android:layout_height="wrap_content">


<!--Layout One--> ​

<!--Layout Two-->


</com.ramotion.foldingcell.FoldingCell>


Almost done! Two steps remain! For correct animation, you need to set up two properties on the root element(s) of your Folding Cell: ​




android:clipChildren="false"



android:clipToPadding="false"




In your Java class



 // get our folding cell
final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);

// attach click listener to folding cell
fc.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
fc.toggle(false);

);





share|improve this answer













See FoldingCell for Android for more help.



In your build.gradle()



dependencies
implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'



In you XML layout



<com.ramotion.foldingcell.FoldingCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/folding_cell"
android:layout_width="match_parent"
android:layout_height="wrap_content">


<!--Layout One--> ​

<!--Layout Two-->


</com.ramotion.foldingcell.FoldingCell>


Almost done! Two steps remain! For correct animation, you need to set up two properties on the root element(s) of your Folding Cell: ​




android:clipChildren="false"



android:clipToPadding="false"




In your Java class



 // get our folding cell
final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);

// attach click listener to folding cell
fc.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
fc.toggle(false);

);






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 6:02









Ali AhmedAli Ahmed

1,3411314




1,3411314












  • android:clipChildren="false" android:clipToPadding="false" where should i keep this steps?

    – AbhiRam
    Nov 15 '18 at 6:04











  • set up two properties on the root element(s) means <com.ramotion.foldingcell.FoldingCell > inside here.,

    – Ali Ahmed
    Nov 15 '18 at 6:07


















  • android:clipChildren="false" android:clipToPadding="false" where should i keep this steps?

    – AbhiRam
    Nov 15 '18 at 6:04











  • set up two properties on the root element(s) means <com.ramotion.foldingcell.FoldingCell > inside here.,

    – Ali Ahmed
    Nov 15 '18 at 6:07

















android:clipChildren="false" android:clipToPadding="false" where should i keep this steps?

– AbhiRam
Nov 15 '18 at 6:04





android:clipChildren="false" android:clipToPadding="false" where should i keep this steps?

– AbhiRam
Nov 15 '18 at 6:04













set up two properties on the root element(s) means <com.ramotion.foldingcell.FoldingCell > inside here.,

– Ali Ahmed
Nov 15 '18 at 6:07






set up two properties on the root element(s) means <com.ramotion.foldingcell.FoldingCell > inside here.,

– Ali Ahmed
Nov 15 '18 at 6:07




















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%2f53313045%2fhow-to-scale-the-view-to-fit-the-content-size-in-android-using-animations%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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3