直播app源码,用户首次登录时弹出左右滑动导航页

直播app源码,用户首次登录时弹出左右滑动导航页

第一步:MainActivity中添加一个跳转导航页的按钮,布局文件activity_main.xml:

 


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:gravity="center"
    tools:context=".MainActivity">
 
    <Button
        android:id="@+id/jump_guide_activity"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="新手引导页" />
 
</LinearLayout>
MainActivity.java代码:
package com.xw.guidepagedemo;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
 
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
 
    private Button mJumpGuidePage;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initview();
        initListener();
    }
    private void initview() {
        //跳转导航页的按钮
        mJumpGuidePage = findViewById(R.id.jump_guide_activity);
    }
 
    private void initListener() {
        //跳转导航页的按钮的点击事件
        mJumpGuidePage.setOnClickListener(this);
    }
 
    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        intent.setClass(this,GuidePageActivity.class);
        startActivity(intent);
    }
}

 第二步:创建导航页的Activity:GuidePageActivity.class和布局文件activity_page_guide.xml:

 


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context=".GuidePageActivity">
 
    <androidx.viewpager.widget.ViewPager
        android:id="@+id/guide_viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
 
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="50dp"
        >
        <!-- 用于动态添加shape圆形灰色小圆点的指示器的布局 -->
        <LinearLayout
            android:id="@+id/indicator_container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        </LinearLayout>
        <!-- 用于遮盖在灰色小圆点上面的红色小圆点 -->
        <ImageView
            android:id="@+id/red_dot"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/shape_circle_selected"
            />
    </RelativeLayout>
 
</RelativeLayout>

 

上面的布局文件中,通过相对布局的进行组件的布局,在ViewPager组件上添加一个相对布局的指示器容器,指示器容器中包含一个用于动态添加shape圆形灰色小圆点的线性布局和一个ImageView组件。

以上就是直播app源码,用户首次登录时弹出左右滑动导航页, 更多内容欢迎关注之后的文章

 

posted @ 2022-04-29 14:07  云豹科技-苏凌霄  阅读(107)  评论(0)    收藏  举报