我正在为RelativeLayout使用右移动动画.
我试图将"可见性"设置为"GONE" onAnimationEnd(),但它不起作用.动画视图仍然存在于停止的位置.
这是我使用的代码:
从右到左创建动画:
TranslateAnimation animate = new TranslateAnimation(0,-rlImages.getWidth()/2,0,0);
animate.setDuration(1000);
animate.setFillAfter(true);
Run Code Online (Sandbox Code Playgroud)
将动画设置为布局:
centre_leftanimate.startAnimation(animate);
Run Code Online (Sandbox Code Playgroud)
添加侦听器到动画:
animate.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
centre_leftanimate.setVisibility(View.GONE); // I wants to make the visibility of view to gone,but this is not working
half_left.setVisibility(View.VISIBLE);
}
});
Run Code Online (Sandbox Code Playgroud)
如何在动画结束后使动画视图的可见性不可见?
请建议.
[2013-04-06 14:48:32 - SplitPaneLayout-Demo] Android Launch!
[2013-04-06 14:48:32 - SplitPaneLayout-Demo] adb is running normally.
[2013-04-06 14:48:32 - SplitPaneLayout-Demo] Performing com.mobidevelop.widget.Demo activity launch
[2013-04-06 14:48:32 - SplitPaneLayout-Demo] Automatic Target Mode: using device '015d188469381013'
[2013-04-06 14:48:32 - SplitPaneLayout-Demo] Uploading SplitPaneLayout-Demo.apk onto device '015d188469381013'
[2013-04-06 14:48:32 - SplitPaneLayout-Demo] Installing SplitPaneLayout-Demo.apk...
[2013-04-06 14:48:34 - SplitPaneLayout-Demo] Installation error: INSTALL_FAILED_UID_CHANGED
[2013-04-06 14:48:34 - SplitPaneLayout-Demo] Please check logcat output for more details.
[2013-04-06 14:48:34 - SplitPaneLayout-Demo] Launch canceled!
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我要求在同一textView上使用单击和拖动事件.
我写了以下代码:
switch(event.getAction())
{
case MotionEvent.ACTION_UP:
// TextDialog.setVisibility(View.VISIBLE);
break;
case MotionEvent.ACTION_DOWN: {
disallowTouch(parent, true);
int downX = (int)event.getX();
int downY = (int)event.getY();
return false; // allow other events like Click to be processed
}
case MotionEvent.ACTION_MOVE:
int x = (int)event.getRawX();
int y= (int)event.getRawY();
layoutParams.leftMargin = x - 50;
layoutParams.topMargin = y - 70;
tvText.setLayoutParams(layoutParams);
break;
default:
break;
}
}
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
TextDialog.setVisibility(View.VISIBLE);
}
Run Code Online (Sandbox Code Playgroud)
但只有Action_Move正在运行,onClick事件不会被触发.
我只想在单击TextView时显示一个对话框.
我怎样才能做到这一点?
在我的应用程序中,我想只在其父布局中拖动图像,但它在整个设备屏幕中拖动.我尽力实现这一目标,但没有找到任何解决方案.
我在这里添加了我的xml和代码.我搜索了这个,但无法找到解决方案.任何人都可以帮我解决这个问题?
我在图片中清楚地提到了我想要实现的目标.我想限制图像拖动那些y1和y2值.
我的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:id="@+id/mainlayout"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="@+id/images">
<!-- cartoon image -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_1"
android:layout_centerInParent="true"
android:id="@+id/cartoon_image">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/play_btn"
android:orientation="horizontal"
android:layout_centerInParent="true"
android:id="@+id/play_btn"
>
</RelativeLayout>
</RelativeLayout>
<!-- end of cartoon image -->
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的活动:
public class MainActivity extends Activity {
RelativeLayout rlImages,Cartoon_image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Cartoon_image=(RelativeLayout)findViewById(R.id.cartoon_image);
rlImages=(RelativeLayout)findViewById(R.id.images);
rlImages.setOnDragListener(new MyDragListener());
Cartoon_image.setOnTouchListener(new MyTouchListener());
}
private final class MyTouchListener implements OnTouchListener {
public boolean onTouch(View view, …Run Code Online (Sandbox Code Playgroud) 我正在使用 Youtube Player api 在我的应用程序中播放 youtube 视频。我想从假设 36 秒开始视频,并想在大约 65 秒结束这个视频。
示例:https : //www.youtube.com/v/BmOpD46eZoA?start=36&end=65
我正在使用 youtubeAndroidPlayer Api。我没有找到任何 Youtubeplayer 设置开始和结束值的方法。谁能建议我如何设置参数。
而且我还希望使用 youtube api 中的“控件”字段隐藏控件,但我没有找到任何隐藏它的方法。
我的xml:
<LinearLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"
android:layout_gravity="center_horizontal"
android:autoLink="web" />
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtubeplayerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的活动:
public class MainActivity extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener{
public static final String API_KEY = "AIzaSyCe6tORd9Ch4lx-9Ku5SQ476uS9OtZYsWA";
public static final String VIDEO_ID = "xyoajjlPt_o";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); …Run Code Online (Sandbox Code Playgroud) 我正在使用 Youtube 播放器来播放 YouTube 视频。我不断收到广告,5 秒后我需要跳过。我只是想在播放 YouTube 视频时阻止这些内容。我有机会这样做吗?
我有一个ImagaView,我在其中设置位图并使用onTouchListener概念进行一些旋转.
If I set another Bitmap to same imageview,it is displaying in same angle which is left after doing rotation of previous image.
Run Code Online (Sandbox Code Playgroud)
所以,我只想让ImageView进入默认位置.
谢谢
我正在使用以下动画在 android 中获得心脏吹动效果,但动画看起来像心脏符号变小然后变大,但我想要反之亦然效果(首先它应该变大然后变小)。
我真的不明白如何修改这个动画以获得大图像。
使用的动画:
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="1"
android:repeatMode="reverse"
android:toXScale="0.5"
android:toYScale="0.5" />
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题。