diff --git a/alertview/build.gradle b/alertview/build.gradle
index 6349e71..e5fe5ef 100644
--- a/alertview/build.gradle
+++ b/alertview/build.gradle
@@ -6,13 +6,13 @@ version = "1.0.0"
android {
compileSdkVersion 21
- buildToolsVersion "20.0.0"
+ buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
- versionCode 1
- versionName "1.0"
+ versionCode 2
+ versionName "1.0.1"
}
buildTypes {
release {
diff --git a/alertview/src/main/java/com/bigkoo/alertview/AlertView.java b/alertview/src/main/java/com/bigkoo/alertview/AlertView.java
index bf1dc99..c63895d 100644
--- a/alertview/src/main/java/com/bigkoo/alertview/AlertView.java
+++ b/alertview/src/main/java/com/bigkoo/alertview/AlertView.java
@@ -2,6 +2,7 @@
import android.app.Activity;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Typeface;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -132,16 +133,29 @@ protected void initHeaderView(ViewGroup viewGroup){
//标题和消息
TextView tvAlertTitle = (TextView) viewGroup.findViewById(R.id.tvAlertTitle);
TextView tvAlertMsg = (TextView) viewGroup.findViewById(R.id.tvAlertMsg);
+
+ //获取msg部分的bottom margin
+ int dimenMsgBottomMargin = 0;
+
if(title != null) {
tvAlertTitle.setText(title);
}else{
tvAlertTitle.setVisibility(View.GONE);
+ try {
+ //标题不可见时顶部增加padding与底部margin相同保证消息垂直居中
+ dimenMsgBottomMargin = context.getResources().getDimensionPixelSize(R.dimen.marginBottom_alert_msg);
+ }
+ catch (Resources.NotFoundException e) {
+ dimenMsgBottomMargin = 0;
+ }
}
if(msg != null) {
tvAlertMsg.setText(msg);
}else{
tvAlertMsg.setVisibility(View.GONE);
}
+
+ tvAlertMsg.setPadding(0, dimenMsgBottomMargin, 0, 0);
}
protected void initListView(){
ListView alertButtonListView = (ListView) contentContainer.findViewById(R.id.alertButtonListView);
diff --git a/app/build.gradle b/app/build.gradle
index f78b296..2b7b372 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 21
- buildToolsVersion "20.0.0"
+ buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.bigkoo.alertviewdemo"
minSdkVersion 14
targetSdkVersion 21
- versionCode 1
- versionName "1.0"
+ versionCode 2
+ versionName "1.0.1"
}
buildTypes {
release {
diff --git a/app/src/main/java/com/bigkoo/alertviewdemo/MainActivity.java b/app/src/main/java/com/bigkoo/alertviewdemo/MainActivity.java
index 66585c8..ac3e567 100644
--- a/app/src/main/java/com/bigkoo/alertviewdemo/MainActivity.java
+++ b/app/src/main/java/com/bigkoo/alertviewdemo/MainActivity.java
@@ -75,6 +75,10 @@ public void alertShow6(View view) {
this, AlertView.Style.ActionSheet, this).show();
}
+ public void alertShow7(View view) {
+ new AlertView(null, "内容", null, null, new String[]{"确定"}, this, AlertView.Style.Alert, this).show();
+ }
+
public void alertShowExt(View view) {
mAlertViewExt.show();
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 3baf8f5..fde3854 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -18,6 +18,10 @@
android:layout_marginTop="5dp"
android:layout_height="50dp"
android:onClick="alertShow3"/>
+