Привет им пытается добавить простое наложение на мое приложение, чтобы выделить биты и качается пользователю я в настоящее время после этого краткого руководства http://www.christianpeeters.com/android-tutorials/android-tutorial-overlay-with-user-instructions/ , но я получаю сообщение об ошибке с помощью Android Studio не могу решить переменную topLeveLayout im полный новичок и попробовал сравнения, чтобы заставить это сделать какие-либо предложения?Использования наложений для обучения пользователя андроида
вот мой 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" >
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="match_parent"
android:layout_height="55dp"
android:text="@string/bath2"
android:id="@+id/bath_text_View"
android:textSize="23sp"
android:gravity="center"
android:textStyle="bold|italic" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/bath_text_View"
android:contentDescription="@string/bathable2"
android:src="@drawable/pic5"
android:layout_above="@+id/nextbutton"
android:id="@+id/imageView"
android:scaleType="centerCrop"
android:cropToPadding="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next"
android:id="@+id/nextbutton"
android:textSize="20sp"
android:textStyle="bold|italic"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:onClick="nextImage2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:background="@android:color/transparent"
android:layout_above="@+id/button4"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/button4"
android:background="@android:color/transparent"
android:layout_above="@+id/button"
android:layout_alignParentLeft="true"
android:clickable="false" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true" />
</RelativeLayout>
<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:contentDescription="@string/overlay"
android:src="@drawable/hint_menu" />
</RelativeLayout>
</FrameLayout>
Так у меня есть 2 относительные макеты в макете кадра первое время мое приложение и второй под быть наложение
вот мой .java
public class bathactivity2 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bath_2);
topLevelLayout = findViewById(R.id.top_layout);
if (isFirstTime()) {
topLevelLayout.setVisibility(View.INVISIBLE);
}
Button button2 = (Button) findViewById(R.id.button2);
Button button4 = (Button) findViewById(R.id.button4);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(bathactivity2.this, R.raw.rubber_duck);
mp.start();
}
});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(bathactivity2.this, R.raw.bubbles);
mp.start();
}
});
}
public void nextImage2(View view){
Intent intent = new Intent(this, BathActivity3.class);
startActivity(intent);
}
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;
}
}
это просто изображение с несколькими скрытыми кнопками на нем, поэтому причина, по которой я хотел бы наложить, указать, где находятся кнопки, я получаю ошибки, которые не могут решить topLevelLayout cann ot разрешить событие движения и другие, это просто случай объявления этих первых, и если да, то как? это что-то вроде
Layout topLevelLayout;
или там что-то хуже происходит здесь спасибо за любую помощь
Почему вы используете оверлейный макет? – zanky
Вид игры для детей только изображение со скрытыми кнопками на нем, которые делают шумы, когда эта часть изображения нажата, поэтому я хочу, чтобы наложение указывало, где находятся кнопки – martinseal1987
@zanky любые идеи? – martinseal1987