diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..69ef058 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +.idea +.DS_Store +build +/captures +.externalNativeBuild +local.properties + diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..c00bba8 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,29 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 24 + buildToolsVersion "24.0.1" + defaultConfig { + applicationId "com.siberiadante" + minSdkVersion 16 + targetSdkVersion 24 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:24.2.1' + testCompile 'junit:junit:4.12' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..ff310b4 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in E:\AndroidStudio\Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/com/siberiadante/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/siberiadante/ExampleInstrumentedTest.java new file mode 100644 index 0000000..da0324b --- /dev/null +++ b/app/src/androidTest/java/com/siberiadante/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.siberiadante; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.siberiadante", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f17bf0e --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/siberiadante/MainActivity.java b/app/src/main/java/com/siberiadante/MainActivity.java new file mode 100644 index 0000000..3b59f50 --- /dev/null +++ b/app/src/main/java/com/siberiadante/MainActivity.java @@ -0,0 +1,50 @@ +package com.siberiadante; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.Gravity; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + } + + public void buttonOne(View view) { + Toast toast=new Toast(this); + ImageView imageView = new ImageView(this);//创建图片控件 + imageView.setImageResource(R.mipmap.ic_launcher);//给控件设置图片 + toast.setView(imageView);//把图片绑定到Toast上 + toast.setDuration(Toast.LENGTH_LONG);//Toast显示的时间; + //设置图片显示的位置:三个参数 + //第一个:位置,可以用|添加并列位置,第二个:相对于X的偏移量,第三个:相对于Y轴的偏移量 + //注意一点:第二和第三个参数是相对于第一个参数设定的位置偏移的 + toast.setGravity(Gravity.TOP|Gravity.RIGHT,0,100); + toast.show();//显示Toast + } + + public void buttonTwo(View view) { + Toast toast=new Toast(this); + LinearLayout linearLayout=new LinearLayout(this);//创建线性布局 + linearLayout.setOrientation(LinearLayout.VERTICAL);//设置布局垂直 + ImageView imageView = new ImageView(this);//创建图片控件 + imageView.setImageResource(R.mipmap.ic_launcher);//给控件设置图片 + TextView textView = new TextView(this);//创建文本控件 + textView.setText("神话丿小王子是不是很帅");//设置文本内容 + linearLayout.addView(imageView);//添加图片控件到布局中 + linearLayout.addView(textView);//添加文本控件到布局中。注意添加顺序会影响图片在前还是为本在前 + toast.setView(linearLayout);//把布局绑定到Toast上 + toast.setDuration(Toast.LENGTH_LONG);//Toast显示的时间; + //参数同前面 + toast.setGravity(Gravity.CENTER,0,0); + toast.show();//显示Toast + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..092ead0 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,23 @@ + + + +