前言:
这个功能很多app都会用到,为了更好的用户体验,这个提示是很有必要的。
首先看下我实现功能上效果截图:(应用为平板专用)
实现思路:
一、在布局xml里面加上一个相对布局,设置一个背景颜色background #91353535,并设置的透明度alpha 30,然后相对布局加入提示图片的控件ImageView。
二、通过SharedPreferences存储是否第一次进入变量,第一次默认甚至为true,当点击提示背景后,将背景控件隐藏,并将变量设置为false,下次进入该界面时,就会不在显示按钮操作提示背景。
核心代码:
xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_grade_query_title"
style="@style/style_text_20"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_gravity="center"
android:background="@color/white"
android:gravity="center"
android:text="测评对象名单"
android:textColor="@color/black"
android:textSize="20sp"
android:layout_weight="7"/>
<ImageView
android:id="@+id/iv_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"