<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/button1"
android:layout_height="wrap_content"
android:layout_width="300dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Button" />
</RelativeLayout>
</RelativeLayout>
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.RelativeLayout;
public class MainActivity extends Activity {
private static final int MESSAGE_SCROLL_TO = 1;
private static final int FRAME_OUT = 30;
private static final int DELAYED_TIME = 30;
private RelativeLayout button;
private int mcount;
private Handler handler = new Handler(){
public void handleMessage(Message msg){
switch (msg.what) {
case MESSAGE_SCROLL_TO:
mcount++;
if (mcount <= FRAME_OUT) {
float fraction = mcount / (float)FRAME_OUT;
int scrollx =(int) (fraction * 100);
button.scrollTo(scrollx, 0);
handler.sendEmptyMessageDelayed(MESSAGE_SCROLL_TO, DELAYED_TIME);
}
break;
default:
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (RelativeLayout) findViewById(R.id.button1);
handler.sendEmptyMessageDelayed(MESSAGE_SCROLL_TO, DELAYED_TIME);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有