diff --git a/DropDownMenu.iml b/DropDownMenu.iml
index a164e72..6981f2b 100644
--- a/DropDownMenu.iml
+++ b/DropDownMenu.iml
@@ -13,7 +13,7 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 3ba1093..0413c5d 100644
--- a/README.md
+++ b/README.md
@@ -5,12 +5,12 @@
我的博客 [自己造轮子--android常用多条件帅选菜单实现思路(类似美团,爱奇艺电影票下拉菜单)](http://www.jianshu.com/p/d9407f799d2d)
-##特色
+## 特色
- 支持多级菜单
- 你可以完全自定义你的菜单样式,我这里只是封装了一些实用的方法,Tab的切换效果,菜单显示隐藏效果等
- 并非用popupWindow实现,无卡顿
-##ScreenShot
+## ScreenShot
Download APK
@@ -19,7 +19,7 @@
-##Gradle Dependency
+## Gradle Dependency
```
allprojects {
@@ -30,11 +30,11 @@ allprojects {
}
dependencies {
- compile 'com.github.dongjunkun:DropDownMenu:1.0.3'
+ compile 'com.github.dongjunkun:DropDownMenu:1.0.4'
}
```
-##使用
+## 使用
添加DropDownMenu 到你的布局文件,如下
```
```
@@ -61,5 +62,7 @@ mDropDownMenu.setDropDownMenu(tabs, popupViews, contentView);
```
如果你要了解更多,可以直接看源码 Example
-##关于我
+> 建议拷贝代码到项目中使用,拷贝DropDownMenu.java 以及res下的所有文件即可
+
+## 关于我
简书[dongjunkun](http://www.jianshu.com/users/f07458c1a8f3/latest_articles)
diff --git a/app/app.iml b/app/app.iml
index 69b9701..e994da9 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -9,13 +9,9 @@
-
-
-
- generateDebugAndroidTestSources
generateDebugSources
@@ -28,19 +24,21 @@
-
+
+
+
@@ -48,51 +46,67 @@
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
-
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index ced36b0..e885092 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.yyy.djk.dropdownmenu"
minSdkVersion 14
- targetSdkVersion 23
+ targetSdkVersion 25
versionCode 1
versionName "1.0"
}
@@ -21,7 +21,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:23.1.1'
+ compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.jakewharton:butterknife:6.1.0'
compile project(':library')
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 200eb11..3493ce9 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -9,6 +9,7 @@
app:ddtextSelectedColor="@color/drop_down_selected"
app:dddividerColor="@color/gray"
app:ddunderlineColor="@color/gray"
+ app:ddmenuMenuHeightPercent="0.5"
app:ddmenuSelectedIcon="@mipmap/drop_down_selected_icon"
app:ddmaskColor="@color/mask_color"
app:ddmenuBackgroundColor="@color/white"
diff --git a/app/src/main/res/layout/item_default_drop_down.xml b/app/src/main/res/layout/item_default_drop_down.xml
index e7c24e9..c9c6ae9 100644
--- a/app/src/main/res/layout/item_default_drop_down.xml
+++ b/app/src/main/res/layout/item_default_drop_down.xml
@@ -1,17 +1,15 @@
+ android:orientation="vertical">
-
-
-
- generateDebugAndroidTestSources
generateDebugSources
@@ -23,24 +19,27 @@
-
+
+
+
+
@@ -48,44 +47,66 @@
-
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
index e727623..f62c792 100644
--- a/library/src/main/AndroidManifest.xml
+++ b/library/src/main/AndroidManifest.xml
@@ -1,11 +1,2 @@
-
-
-
-
-
-
+
diff --git a/library/src/main/java/com/yyydjk/library/DeviceUtils.java b/library/src/main/java/com/yyydjk/library/DeviceUtils.java
new file mode 100644
index 0000000..cd221da
--- /dev/null
+++ b/library/src/main/java/com/yyydjk/library/DeviceUtils.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Peng fei Pan
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.yyydjk.library;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.graphics.Point;
+import android.os.Build;
+import android.view.Display;
+import android.view.WindowManager;
+
+/**
+ * 设备工具箱,提供与设备硬件相关的工具方法
+ */
+public class DeviceUtils {
+
+ /**
+ * 获取屏幕尺寸
+ */
+ @SuppressWarnings("deprecation")
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
+ public static Point getScreenSize(Context context){
+ WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ Display display = windowManager.getDefaultDisplay();
+ if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2){
+ return new Point(display.getWidth(), display.getHeight());
+ }else{
+ Point point = new Point();
+ display.getSize(point);
+ return point;
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/yyydjk/library/DropDownMenu.java b/library/src/main/java/com/yyydjk/library/DropDownMenu.java
index 92f8480..fa3a8f2 100644
--- a/library/src/main/java/com/yyydjk/library/DropDownMenu.java
+++ b/library/src/main/java/com/yyydjk/library/DropDownMenu.java
@@ -50,6 +50,8 @@ public class DropDownMenu extends LinearLayout {
//tab未选中图标
private int menuUnselectedIcon;
+ private float menuHeighPercent = 0.5f;
+
public DropDownMenu(Context context) {
super(context, null);
@@ -77,6 +79,7 @@ public DropDownMenu(Context context, AttributeSet attrs, int defStyleAttr) {
menuTextSize = a.getDimensionPixelSize(R.styleable.DropDownMenu_ddmenuTextSize, menuTextSize);
menuSelectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuSelectedIcon, menuSelectedIcon);
menuUnselectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuUnselectedIcon, menuUnselectedIcon);
+ menuHeighPercent = a.getFloat(R.styleable.DropDownMenu_ddmenuMenuHeightPercent,menuHeighPercent);
a.recycle();
//初始化tabMenuView并添加到tabMenuView
@@ -128,8 +131,12 @@ public void onClick(View v) {
});
containerView.addView(maskView, 1);
maskView.setVisibility(GONE);
+ if (containerView.getChildAt(2) != null){
+ containerView.removeViewAt(2);
+ }
popupMenuViews = new FrameLayout(getContext());
+ popupMenuViews.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (DeviceUtils.getScreenSize(getContext()).y*menuHeighPercent)));
popupMenuViews.setVisibility(GONE);
containerView.addView(popupMenuViews, 2);
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index cf5bf47..cf25ade 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -11,5 +11,6 @@
+
\ No newline at end of file
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
deleted file mode 100644
index 6d51856..0000000
--- a/library/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Library
-