我正在使用一个ViewSwitcher,它可以让我轻松地在内置动画的两个不同的List Headers之间来回切换.
然而,问题是两个视图的高度变化很大,看起来ViewSwitcher用来layout_height="wrap_content"测量两个孩子并将两个高度中较大的一个视为自己的高度.当显示时,这会在较小视图的正下方产生大量不需要的空白区域.
我理解为什么这是理想的ViewSwitcher行为,但它不希望My App行为.
示例:
Say View A高50dp,View B高100dp,两者都作为子项添加到ViewSwitcher.即使View A显示,ViewSwitcher总是高达100dp.
我想要的是能够在A和B之间切换并使ViewSwitcher缩小或增长以适合当前显示的任何视图.我怎样才能做到这一点?
我试图动画两层drawable,以达到后蜂窝不确定进度指标的效果.XML非常简单,但似乎只有一个层在Honeycomb之前的平台上运行时才会生成动画.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:drawable="@drawable/abs__spinner_48_outer_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="1080" />
</item>
<item>
<rotate
android:drawable="@drawable/abs__spinner_48_inner_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="720"
android:toDegrees="0" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
这仅仅是这些平台的限制,还是我可以使用的替代语法(通常是在API11之前或专门针对API11)来实现所需的功能?
我创建了一个由ViewSwitcher组成的广告控件....
在该控件中我有ImageView和TextView,因为广告是文本或图像..
现在我必须给advetisements动画..
我试过以下
动画inAnimation = AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left); inAnimation.setDuration(1500);
动画outAnimation = AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right); outAnimation.setDuration(1500);
我把它设置为切换台
ViewSwitcher切换器;
switcher.setInAnimation(inAnimation);
switcher.setOutAnimation(outAnimation);
但它不会工作..
请给我任何其他选择..或者如果使用上面的代码是错误的,那么如何使用它?
我有个问题.我想动画的背景颜色的LinearLayout使用ObjectAnimator.
问题是,它的动画,但它确实存在期间也没有保健valueFrom和valueTo.
这是我的xml文件:
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:propertyName="backgroundColor"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="#FF0000"
android:valueTo="#000000" />
Run Code Online (Sandbox Code Playgroud)
在Java中我称之为:
ObjectAnimator objAnim = (ObjectAnimator)AnimatorInflater.loadAnimator(getActivity(), R.animator.animator_bkg);
objAnim.setTarget(view);
objAnim.start();
Run Code Online (Sandbox Code Playgroud)
请注意,当我为布局的alpha设置动画时,它会按预期工作.
这是Android的bug(华硕Transformer上的4.0.3),还是我错过了什么?
情况如下:
我正在使用API 17引入的子片段.说我有
ActivityA -> FragmentA
ActivityA -> FragmentB
FragmentA -> ChildFragmentA
FragmentA -> ChildFragmentB
Run Code Online (Sandbox Code Playgroud)
所以我正在使用FragmentTransaction ActivityA->FragmentA->ChildFragmentA转换到ActivityA->FragmentA->ChildFragmentB使用动画添加到backstack并弹出backstack(当我转到ChildFragmentB时会有动画,当我按下并移动到ChildFragmentA时会有动画).
现在我导航到ActivityA->FragmentB(FragmentA不再附加).当我导航回到ActivityA->FragmentA哪里ChildFragmentB是可见的,ChildFragmentB动画的,因为它从未来什么时候ChildFragmentA.
我想在恢复时禁用此动画Activity->FragmentA.但是在儿童片段之间转换时要保持它.此动画在FragmentTransaction中设置.有没有办法让这种情况发生?
android android-animation android-fragments android-nested-fragment
我正在尝试实现滑动删除和ListView使用SwipeToDismissUndoList库扩展Roman Nurik的SwipeToDismiss示例.
我的问题在于删除动画.由于ListView由a支持CursorAdapter,动画会触发onDismiss回调,onAnimationEnd但这意味着动画已经运行并在CursorAdapter使用删除更新之前重置自身.
这最终看起来像是一个闪烁的用户,他们通过滑动它删除一个音符,然后视图返回一瞬间然后消失,因为CursorAdapter已经拾取数据更改.
这是我的OnDismissCallback:
private SwipeDismissList.OnDismissCallback dismissCallback =
new SwipeDismissList.OnDismissCallback() {
@Override
public SwipeDismissList.Undoable onDismiss(ListView listView, final int position) {
Cursor c = mAdapter.getCursor();
c.moveToPosition(position);
final int id = c.getInt(Query._ID);
final Item item = Item.findById(getActivity(), id);
if (Log.LOGV) Log.v("Deleting item: " + item);
final ContentResolver cr = getActivity().getContentResolver();
cr.delete(Items.buildItemUri(id), null, null);
mAdapter.notifyDataSetChanged();
return new SwipeDismissList.Undoable() {
public void undo() …Run Code Online (Sandbox Code Playgroud) 一方面我有一个带有两个ImageView的布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/image_cross2"
android:layout_width="wrap_content"
android:layout_height="@dimen/image_size"
android:layout_gravity="top"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/image_cross1"
android:layout_width="wrap_content"
android:layout_height="@dimen/image_size"
android:layout_gravity="top"
android:scaleType="centerCrop" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
另一方面,我有一个图像资源列表:
static int mImages[] = new int[] {
R.drawable.artistes,
R.drawable.couple1,
R.drawable.couple2,
R.drawable.couple3,
R.drawable.enfant,
R.drawable.manege,
R.drawable.manege2,
R.drawable.metropolitain,
R.drawable.panoramique,
R.drawable.sacrecoeur };
Run Code Online (Sandbox Code Playgroud)
我还有一个由Handler + postDelayed()制作的调度程序,用计时器一个接一个地显示图像.这工作正常
我的问题是关于从一个图像视图到另一个图像视图的过渡动画,知道我每次都要清理图像视图以避免OutOfMemoryExceptions:
现在我在schduled回调方法中这样做:
if (mIndex == mImages.length) {
mIndex = 0; // repeat
}
if (mIndex % 2 != 0) { // pair
mImageCross2.setImageResource(mImages[mIndex++]);
Utils.crossfade(mImageCross2, mImageCross1, 1000/*duration*/);
mImageCross1.setImageResource(0);
} else {
mImageCross1.setImageResource(mImages[mIndex++]);
Utils.crossfade(mImageCross1, mImageCross2, 1000); …Run Code Online (Sandbox Code Playgroud) 我有一个简单的视图scene root FrameLayout,ListView底部包含一个和几个按钮.
scene root用于加载和显示不同的场景,大小根据当前动态变化scene.ListView设置match_parent在两个方向并位于后面scene root.
这是问题所在:
如果我使用底部的按钮开始转换,一切正常,没问题,魔术.但是,如果我在滚动(✝✝)时将(✝)转换到不同的场景,则转换似乎在开始之前闪烁.
看起来渲染引擎无法ListView在由于滚动导致层次结构无效之前加载动画的第一帧.
谢谢您的帮助 ;)
✝ TransitionManager.go(Scene, Transition)
✝✝我添加了几种方法ListView来实现这一点
我正在尝试将视图设置为另一个布局的动画,但我遇到了一个问题,因为我的视图位于布局后面.我尝试过android:animateLayoutChanges="true",但没有成功.
我的代码:
layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<RadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New RadioButton" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:animateLayoutChanges="true"
android:background="#ffffff">
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的活动课:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
float x = 300;
float y = 300;
RadioButton button = (RadioButton) findViewById(R.id.radioButton);
button.animate().setDuration(10000).x(x).y(y);
}
}
Run Code Online (Sandbox Code Playgroud) 我有RecyclerView很多项目,基本上是一些CardView.
这些卡片在他们的身体中间有一个支持文本,GONE默认情况下可见性设置为,VISIBLE当我点击卡片右侧的箭头时,它就会生成.
我正在尝试在文本显示的同时对卡进行动画处理,同时它会崩溃.
下图显示了扩展卡和折叠卡:
该CardView布局(我已经删除了可读性某些部分):
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
android:id="@+id/root">
<LinearLayout
android:id="@+id/item_ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin">
<!-- The header with the title and the item -->
<TextView
android:id="@+id/body_content"
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_marginBottom="8dp"
android:text="@string/about_page_description"
android:textColor="@color/secondaryText"
android:visibility="gone"/>
<!-- The divider, and the footer with the timestamp -->
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
当卡片展开并露出身体时TextView,动画正在工作,但是,当我试图将其折叠回来时,动画片下方的卡片与第一张卡片重叠.
例:
我之前已经在这里问了一个关于这种行为的类似问题,但是这个解决方案并不适用TextView于卡片的中间位置.
负责动画部分的代码在RecyclerView适配器内部.箭头有一个点击监听器,可以调用以下方法:
private …Run Code Online (Sandbox Code Playgroud) android android-animation kotlin android-transitions android-recyclerview