0
내 앱에는 앱이 어떻게 작동하고 어떻게 할 수 있는지를 보여주는 환영 레이아웃 또는 도움말 레이아웃이 있습니다. 앱을 설치할 때 한 번만 표시하고 싶습니다. 그런 다음 다시 표시하지 마십시오. 그리고 이것이 가능한 경우 가장 쉬운 방법은 무엇입니까?android SDK, 한 번 환영 레이아웃
내 앱에는 앱이 어떻게 작동하고 어떻게 할 수 있는지를 보여주는 환영 레이아웃 또는 도움말 레이아웃이 있습니다. 앱을 설치할 때 한 번만 표시하고 싶습니다. 그런 다음 다시 표시하지 마십시오. 그리고 이것이 가능한 경우 가장 쉬운 방법은 무엇입니까?android SDK, 한 번 환영 레이아웃
this과 같은 것을 시도 할 수 있습니다. 두 개의 레이아웃을 만듭니다. 기본 레이아웃과 자습서 레이아웃이 기본보기 상단에 겹쳐집니다. 첫 번째 시간을 확인하고 튜토리얼 레이아웃을 처음으로 표시하는 방법이 있습니다. 처음이 아닌 경우 자습서 레이아웃을 보이지 않게 설정하십시오.
isFirstTime() 메소드
private boolean isFirstTime()
{
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
boolean ranBefore = preferences.getBoolean("RanBefore", false);
if (!ranBefore) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("RanBefore", true);
editor.commit();
topLevelLayout.setVisibility(View.VISIBLE);
topLevelLayout.setOnTouchListener(new View.OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
topLevelLayout.setVisibility(View.INVISIBLE);
return false;
}
});
}
return ranBefore;
}
레이아웃 XML
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_layout" >
<!--Below activity widgets when the transparent layout is gone -->
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient">
<include
android:id="@+id/include1"
layout="@layout/actionbar" />
<ImageView
android:id="@+id/ivDressshirt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvLength"
android:layout_marginTop="55dp"
android:paddingLeft="@dimen/padding10dp"
android:src="@drawable/shirt" />
</RelativeLayout>
<!--Below is the transparent layout positioned at startup -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88666666"
android:id="@+id/top_layout">
<ImageView
android:id="@+id/ivInstruction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingTop="25dp"
android:layout_marginRight="15dp"
android:clickable="false"
android:paddingLeft="20dip"
android:scaleType="center"
android:src="@drawable/help" />
</RelativeLayout>
</FrameLayout>
에서 onCreate()
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
topLevelLayout = findViewById(R.id.top_layout);
if (isFirstTime()) {
topLevelLayout.setVisibility(View.INVISIBLE);
}