Change View height programmatically Smoothly
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to change the height of the view programmatically.
What i have tried is -
RelativeLayout rlOne;
rlOne = (RelativeLayout) findViewById(R.id.rlOne);
And on some click event i am changing the height using the LayoutParams.
rlOne.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, NEWHEIGHT));
The height is increased but the transition is not smooth.
How can i achieve a smooth transition from view's original height to view's new height?
Can i slow down the transition ?
android view height
add a comment |
I am trying to change the height of the view programmatically.
What i have tried is -
RelativeLayout rlOne;
rlOne = (RelativeLayout) findViewById(R.id.rlOne);
And on some click event i am changing the height using the LayoutParams.
rlOne.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, NEWHEIGHT));
The height is increased but the transition is not smooth.
How can i achieve a smooth transition from view's original height to view's new height?
Can i slow down the transition ?
android view height
Why don't you just anmate the transition?
– g00dy
Aug 7 '13 at 7:21
@MocialovBoris : Can u give me some more inputs on this. Shall i use the scale animation?
– Anukool
Aug 7 '13 at 7:32
add a comment |
I am trying to change the height of the view programmatically.
What i have tried is -
RelativeLayout rlOne;
rlOne = (RelativeLayout) findViewById(R.id.rlOne);
And on some click event i am changing the height using the LayoutParams.
rlOne.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, NEWHEIGHT));
The height is increased but the transition is not smooth.
How can i achieve a smooth transition from view's original height to view's new height?
Can i slow down the transition ?
android view height
I am trying to change the height of the view programmatically.
What i have tried is -
RelativeLayout rlOne;
rlOne = (RelativeLayout) findViewById(R.id.rlOne);
And on some click event i am changing the height using the LayoutParams.
rlOne.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, NEWHEIGHT));
The height is increased but the transition is not smooth.
How can i achieve a smooth transition from view's original height to view's new height?
Can i slow down the transition ?
android view height
android view height
edited Jan 3 at 7:09
Cœur
19.3k10116155
19.3k10116155
asked Aug 7 '13 at 7:20
AnukoolAnukool
2,73182236
2,73182236
Why don't you just anmate the transition?
– g00dy
Aug 7 '13 at 7:21
@MocialovBoris : Can u give me some more inputs on this. Shall i use the scale animation?
– Anukool
Aug 7 '13 at 7:32
add a comment |
Why don't you just anmate the transition?
– g00dy
Aug 7 '13 at 7:21
@MocialovBoris : Can u give me some more inputs on this. Shall i use the scale animation?
– Anukool
Aug 7 '13 at 7:32
Why don't you just anmate the transition?
– g00dy
Aug 7 '13 at 7:21
Why don't you just anmate the transition?
– g00dy
Aug 7 '13 at 7:21
@MocialovBoris : Can u give me some more inputs on this. Shall i use the scale animation?
– Anukool
Aug 7 '13 at 7:32
@MocialovBoris : Can u give me some more inputs on this. Shall i use the scale animation?
– Anukool
Aug 7 '13 at 7:32
add a comment |
4 Answers
4
active
oldest
votes
Play with from/to/speed values
ScaleAnimation scaleAnimation = new ScaleAnimation(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rlOne.setAnimation(scaleAnimation);
Source:
https://stackoverflow.com/a/1624689/1276374
is there any thing except scale because if i scale the textView from one side, it does not look decreasing width, it look like comprising
– Furqan
Jul 31 '17 at 16:31
add a comment |
Basically the idea is that, you calculate the new height (the height after your view increasing) view first and write an thread, increase the height of you old view (the height of your view before increasing) pixel by pixel(may be 5-10 pixels at a time) until it reaches the new height. Hope the idea could help.
+1 for the idea.
– Anukool
Aug 7 '13 at 7:31
add a comment |
You could write a for loop, where the view's height is increased by very little, than a pause is made before increasing the counter. In this way, the user will have the impression of a smooth transition.
+1. for the input. I will try it out.
– Anukool
Aug 7 '13 at 7:31
add a comment |
Use
LinearLayout linearLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Doesn't compile, you're assigning a reference to an Object of typeLinearLayout.LayoutParams
to a variable of typeLinearLayout
.
– urgentx
May 23 '18 at 22:15
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18097039%2fchange-view-height-programmatically-smoothly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Play with from/to/speed values
ScaleAnimation scaleAnimation = new ScaleAnimation(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rlOne.setAnimation(scaleAnimation);
Source:
https://stackoverflow.com/a/1624689/1276374
is there any thing except scale because if i scale the textView from one side, it does not look decreasing width, it look like comprising
– Furqan
Jul 31 '17 at 16:31
add a comment |
Play with from/to/speed values
ScaleAnimation scaleAnimation = new ScaleAnimation(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rlOne.setAnimation(scaleAnimation);
Source:
https://stackoverflow.com/a/1624689/1276374
is there any thing except scale because if i scale the textView from one side, it does not look decreasing width, it look like comprising
– Furqan
Jul 31 '17 at 16:31
add a comment |
Play with from/to/speed values
ScaleAnimation scaleAnimation = new ScaleAnimation(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rlOne.setAnimation(scaleAnimation);
Source:
https://stackoverflow.com/a/1624689/1276374
Play with from/to/speed values
ScaleAnimation scaleAnimation = new ScaleAnimation(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rlOne.setAnimation(scaleAnimation);
Source:
https://stackoverflow.com/a/1624689/1276374
edited May 23 '17 at 12:06
Community♦
11
11
answered Aug 7 '13 at 7:43
Boris MocialovBoris Mocialov
2,60811648
2,60811648
is there any thing except scale because if i scale the textView from one side, it does not look decreasing width, it look like comprising
– Furqan
Jul 31 '17 at 16:31
add a comment |
is there any thing except scale because if i scale the textView from one side, it does not look decreasing width, it look like comprising
– Furqan
Jul 31 '17 at 16:31
is there any thing except scale because if i scale the textView from one side, it does not look decreasing width, it look like comprising
– Furqan
Jul 31 '17 at 16:31
is there any thing except scale because if i scale the textView from one side, it does not look decreasing width, it look like comprising
– Furqan
Jul 31 '17 at 16:31
add a comment |
Basically the idea is that, you calculate the new height (the height after your view increasing) view first and write an thread, increase the height of you old view (the height of your view before increasing) pixel by pixel(may be 5-10 pixels at a time) until it reaches the new height. Hope the idea could help.
+1 for the idea.
– Anukool
Aug 7 '13 at 7:31
add a comment |
Basically the idea is that, you calculate the new height (the height after your view increasing) view first and write an thread, increase the height of you old view (the height of your view before increasing) pixel by pixel(may be 5-10 pixels at a time) until it reaches the new height. Hope the idea could help.
+1 for the idea.
– Anukool
Aug 7 '13 at 7:31
add a comment |
Basically the idea is that, you calculate the new height (the height after your view increasing) view first and write an thread, increase the height of you old view (the height of your view before increasing) pixel by pixel(may be 5-10 pixels at a time) until it reaches the new height. Hope the idea could help.
Basically the idea is that, you calculate the new height (the height after your view increasing) view first and write an thread, increase the height of you old view (the height of your view before increasing) pixel by pixel(may be 5-10 pixels at a time) until it reaches the new height. Hope the idea could help.
answered Aug 7 '13 at 7:24
user2652394user2652394
1,55411015
1,55411015
+1 for the idea.
– Anukool
Aug 7 '13 at 7:31
add a comment |
+1 for the idea.
– Anukool
Aug 7 '13 at 7:31
+1 for the idea.
– Anukool
Aug 7 '13 at 7:31
+1 for the idea.
– Anukool
Aug 7 '13 at 7:31
add a comment |
You could write a for loop, where the view's height is increased by very little, than a pause is made before increasing the counter. In this way, the user will have the impression of a smooth transition.
+1. for the input. I will try it out.
– Anukool
Aug 7 '13 at 7:31
add a comment |
You could write a for loop, where the view's height is increased by very little, than a pause is made before increasing the counter. In this way, the user will have the impression of a smooth transition.
+1. for the input. I will try it out.
– Anukool
Aug 7 '13 at 7:31
add a comment |
You could write a for loop, where the view's height is increased by very little, than a pause is made before increasing the counter. In this way, the user will have the impression of a smooth transition.
You could write a for loop, where the view's height is increased by very little, than a pause is made before increasing the counter. In this way, the user will have the impression of a smooth transition.
answered Aug 7 '13 at 7:22
RaduRadu
324314
324314
+1. for the input. I will try it out.
– Anukool
Aug 7 '13 at 7:31
add a comment |
+1. for the input. I will try it out.
– Anukool
Aug 7 '13 at 7:31
+1. for the input. I will try it out.
– Anukool
Aug 7 '13 at 7:31
+1. for the input. I will try it out.
– Anukool
Aug 7 '13 at 7:31
add a comment |
Use
LinearLayout linearLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Doesn't compile, you're assigning a reference to an Object of typeLinearLayout.LayoutParams
to a variable of typeLinearLayout
.
– urgentx
May 23 '18 at 22:15
add a comment |
Use
LinearLayout linearLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Doesn't compile, you're assigning a reference to an Object of typeLinearLayout.LayoutParams
to a variable of typeLinearLayout
.
– urgentx
May 23 '18 at 22:15
add a comment |
Use
LinearLayout linearLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Use
LinearLayout linearLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
answered Aug 7 '13 at 7:50
MasterMaster
2,07832657
2,07832657
Doesn't compile, you're assigning a reference to an Object of typeLinearLayout.LayoutParams
to a variable of typeLinearLayout
.
– urgentx
May 23 '18 at 22:15
add a comment |
Doesn't compile, you're assigning a reference to an Object of typeLinearLayout.LayoutParams
to a variable of typeLinearLayout
.
– urgentx
May 23 '18 at 22:15
Doesn't compile, you're assigning a reference to an Object of type
LinearLayout.LayoutParams
to a variable of type LinearLayout
.– urgentx
May 23 '18 at 22:15
Doesn't compile, you're assigning a reference to an Object of type
LinearLayout.LayoutParams
to a variable of type LinearLayout
.– urgentx
May 23 '18 at 22:15
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18097039%2fchange-view-height-programmatically-smoothly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Why don't you just anmate the transition?
– g00dy
Aug 7 '13 at 7:21
@MocialovBoris : Can u give me some more inputs on this. Shall i use the scale animation?
– Anukool
Aug 7 '13 at 7:32