稍微模仿了下Lofter的开启画面

博主分享了自己模仿Lofter启动画面的实践过程,代码简单易懂,主要展示了XML布局代码,着重于功能实现而非视觉优化。提供了Demo地址供读者参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    之前一直很喜欢Lofter的启动画面,今天刚好项目需要,自己尝试用自己的方式去实现,代码相对比较简单,并没有复杂的地方,这里就直接po上代码了,也不多讲解了,这个估计一看就懂了的。当然没纠结在布局上,所以,不是很认真的在布局上下工夫,实现功能为主:

  XML布局代码如下:

    splash.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#D30F11" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <RelativeLayout
            android:id="@+id/layout_firstIn"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/image_c"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_marginLeft="150dp"
                android:layout_marginTop="24dp"
                android:layout_marginBottom="30dp"
                android:src="@drawable/logo" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/image_c"
                android:layout_toRightOf="@+id/image_c"
                android:text="SDN"
                android:textColor="@android:color/white"
                android:textSize="50sp" />
        </RelativeLayout>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/layout_secondIn"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/init_pic"
        android:visibility="invisible" >
    </RelativeLayout>

</FrameLayout>

程序的代码实现如下:

   

public class SplashActivity extends Activity {

	private RelativeLayout img_secondIn;

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

		img_secondIn = (RelativeLayout) findViewById(R.id.layout_secondIn);

		img_secondIn.setVisibility(View.VISIBLE);
		AlphaAnimation aa = new AlphaAnimation(0.0f, 1.0f);
		aa.setDuration(5000);
		img_secondIn.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {

			// 动画开始时便调用此方法
			@Override
			public void onAnimationStart(Animation animation) {

			}

			// 动画重复播放时调用此方法
			@Override
			public void onAnimationRepeat(Animation animation) {

			}

			// 动画结束时调用此方法
			@Override
			public void onAnimationEnd(Animation animation) {
				Intent intent = new Intent(SplashActivity.this,
						MainActivity.class);
				startActivity(intent);
			}
		});

	}

}

也就这样而已,图就不上了,那就传下demo地址吧:

地址点这

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值