我是android新手。 我想在Activity上显示全屏图像,如图层, 当我点击按钮我想要调用新活动但在活动之前我想在该活动上显示一个图像(全屏)5秒钟。像广告。我能怎么做 ?请帮我。提前谢谢你。
这是我的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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/black_ng2">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageViewForAd"
android:adjustViewBounds="true"
android:src="@drawable/splash_screen"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginBottom="@dimen/_15sdp"
android:padding="@dimen/_10sdp"
android:id="@+id/cardLayout"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_alignParentRight="true">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginBottom="@dimen/_15sdp"
android:id="@+id/textInputLayoutPooja"
android:textColorHint="@color/colorwhite">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:hint="Date Of Mandal Pooja"
android:id="@+id/txtDateOfPooja"
android:drawableLeft="@drawable/calender"
android:textSize="@dimen/_15sdp"
android:textColor="@color/colorwhite"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginBottom="@dimen/_15sdp"
android:id="@+id/textInputLayoutYaatra"
android:layout_below="@+id/textInputLayoutPooja"
android:textColorHint="@color/colorwhite">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Date Of Yaatra"
android:id="@+id/txtDateOfYaatra"
android:textSize="@dimen/_15sdp"
android:drawableLeft="@drawable/calender"
android:textColor="@color/colorwhite"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginBottom="@dimen/_15sdp"
android:id="@+id/textInputLayoutDarshan"
android:layout_below="@+id/textInputLayoutYaatra"
android:textColorHint="@color/colorwhite">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Date Of Darshan"
android:id="@+id/txtDateOfDarshan"
android:textSize="@dimen/_15sdp"
android:drawableLeft="@drawable/calender"
android:textColor="@color/colorwhite"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="@dimen/_80sdp"
android:layout_height="@dimen/_40sdp"
android:text="Add Yaatra"
android:id="@+id/btnAddYaatra"
android:textSize="@dimen/_15sdp"
android:layout_below="@+id/textInputLayoutDarshan"
android:background="@color/btncolor"
android:textColor="@color/colorwhite"
android:layout_centerHorizontal="true" />
</RelativeLayout>
答案 0 :(得分:0)
在活动的onCreate()中写下这个。
Handler handlers = new Handler();
handlers.postDelayed(new Runnable() {
@Override
public void run() {
ImageView splash=(ImageView)findViewById(R.id.imageViewForAd)
splash.setVisibility(View.GONE);
}
}, 5000);
希望它会对你有所帮助。