package com.kx.myguide;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
/**
* author: kx
* time: 2018/9/3
*/
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button mBt;
private WindowManager mWindowManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBt = (Button) findViewById(R.id.bt);
mBt.setOnClickListener(this);
mWindowManager = getWindowManager();
}
int i = 0;
@Override
public void onClick(View v) {
runOnUiThread(new Runnable() {
@Override
public void run() {
LayoutInflater layoutInflater = getLayoutInflater();
final View guideView = layoutInflater.inflate(R.layout.guide, null);
final ImageView img = guideView.findViewById(R.id.img);
RelativeLayout swtich = guideView.findViewById(R.id.swtich);
swtich.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (i) {
case 0:
img.setBackgroundResource(R.drawable.guidepage2);
i++;
break;
case 1:
img.setBackgroundResource(R.drawable.guidepage3);
i++;
break;
case 2:
img.setBackgroundResource(R.drawable.guidepage4);
i++;
break;
case 3:
i = 0;
mWindowManager.removeView(guideView);
break;
}
}
});
//设置参数
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.type = WindowManager.LayoutParams.TYPE_APPLICATION;
params.format = PixelFormat.RGBA_8888;
params.gravity = Gravity.LEFT | Gravity.TOP;
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
params.width = dm.widthPixels; // 屏幕宽度(像素)
params.height = dm.heightPixels; // 屏幕高度(像素)
mWindowManager.addView(guideView, params);
}
});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
MyGuide.zip (91个子文件)
MyGuide
MyGuide.iml 861B
gradlew.bat 2KB
gradlew 5KB
gradle.properties 747B
.gradle
buildOutputCleanup
cache.properties.lock 2B
built.bin 0B
cache.properties 51B
4.1
taskHistory
taskHistory.lock 17B
taskHistory.bin 63KB
fileSnapshots.bin 1.69MB
fileHashes
fileHashes.lock 17B
fileHashes.bin 226KB
resourceHashesCache.bin 19KB
fileChanges
last-build.bin 1B
fileContent
fileContent.lock 17B
javaCompile
javaCompile.lock 17B
classAnalysis.bin 759KB
taskJars.bin 20KB
taskHistory.bin 98KB
jarAnalysis.bin 318KB
app
proguard-rules.pro 772B
src
test
java
com
kx
myguide
ExampleUnitTest.java 408B
androidTest
java
com
kx
myguide
ExampleInstrumentedTest.java 755B
main
res
mipmap-xxxhdpi
ic_launcher.png 9KB
ic_launcher_round.png 15KB
drawable
guidepage4.png 13KB
guidepage2.png 9KB
guidepage1.png 12KB
guidepage3.png 8KB
ic_launcher_background.xml 6KB
mipmap-hdpi
ic_launcher.png 3KB
ic_launcher_round.png 5KB
drawable-v24
ic_launcher_foreground.xml 2KB
values
colors.xml 214B
strings.xml 73B
styles.xml 394B
mipmap-xxhdpi
ic_launcher.png 6KB
ic_launcher_round.png 10KB
mipmap-mdpi
ic_launcher.png 2KB
ic_launcher_round.png 3KB
mipmap-xhdpi
ic_launcher.png 4KB
ic_launcher_round.png 7KB
mipmap-anydpi-v26
ic_launcher_round.xml 274B
ic_launcher.xml 274B
layout
activity_main.xml 556B
guide.xml 602B
java
com
kx
myguide
MainActivity.java 3KB
AndroidManifest.xml 732B
app.iml 12KB
.gitignore 8B
build.gradle 947B
libs
gradle
wrapper
gradle-wrapper.jar 52KB
gradle-wrapper.properties 236B
.idea
gradle.xml 626B
runConfigurations.xml 564B
misc.xml 2KB
modules.xml 351B
encodings.xml 200B
workspace.xml 194KB
libraries
android_arch_lifecycle_common_1_0_0_jar.xml 546B
com_android_support_constraint_constraint_layout_solver_1_1_2_jar.xml 424B
com_android_support_support_v4_26_1_0.xml 669B
junit_junit_4_12_jar.xml 485B
com_google_code_findbugs_jsr305_2_0_1_jar.xml 358B
com_android_support_appcompat_v7_26_1_0.xml 679B
com_android_support_support_core_ui_26_1_0.xml 694B
android_arch_core_common_1_0_0_jar.xml 531B
com_android_support_test_monitor_1_0_2.xml 659B
org_hamcrest_hamcrest_library_1_3_jar.xml 555B
org_hamcrest_hamcrest_integration_1_3_jar.xml 576B
com_squareup_javawriter_2_1_1_jar.xml 536B
javax_inject_javax_inject_1_jar.xml 526B
com_android_support_support_media_compat_26_1_0.xml 719B
android_arch_lifecycle_runtime_1_0_0.xml 655B
com_android_support_animated_vector_drawable_26_1_0.xml 739B
com_android_support_test_espresso_espresso_core_3_0_2.xml 707B
com_android_support_constraint_constraint_layout_1_1_2.xml 499B
com_android_support_support_core_utils_26_1_0.xml 709B
com_android_support_test_runner_1_0_2.xml 654B
net_sf_kxml_kxml2_2_3_0_jar.xml 285B
com_android_support_support_annotations_26_1_0_jar.xml 606B
org_hamcrest_hamcrest_core_1_3_jar.xml 541B
com_android_support_test_espresso_espresso_idling_resource_3_0_2.xml 762B
com_android_support_support_vector_drawable_26_1_0.xml 734B
com_android_support_support_compat_26_1_0.xml 689B
com_android_support_support_fragment_26_1_0.xml 699B
com_android_support_support_annotations_27_1_1_jar.xml 607B
.gitignore 127B
local.properties 460B
settings.gradle 16B
build.gradle 573B
共 91 条
- 1
资源评论
- 木棉花的春天ls2019-06-01是想要的效果
KX興
- 粉丝: 2428
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功