[Android] SlidingPaneLayout: use a custom attribute to set the overhang size instead of using the minimum height of the slidable child
Adrien Maglo
git at videolan.org
Wed Jan 15 16:53:29 CET 2014
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Wed Jan 15 12:46:47 2014 +0100| [d9883d4194e613880e0d220d03fb2bd29f6dd1c8] | committer: Adrien Maglo
SlidingPaneLayout: use a custom attribute to set the overhang size instead of using the minimum height of the slidable child
The new method is compatible with pre-16 APIs.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=d9883d4194e613880e0d220d03fb2bd29f6dd1c8
---
vlc-android/res/layout/main.xml | 7 ++++---
vlc-android/res/values/attrs.xml | 4 ++++
.../org/videolan/vlc/widget/SlidingPaneLayout.java | 21 +++++++++++++++-----
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/vlc-android/res/layout/main.xml b/vlc-android/res/layout/main.xml
index 1d23196..788c969 100644
--- a/vlc-android/res/layout/main.xml
+++ b/vlc-android/res/layout/main.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<org.videolan.vlc.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:vlc="http://schemas.android.com/apk/res-auto"
android:id="@+id/pane"
android:layout_width="match_parent"
- android:layout_height="match_parent" >
+ android:layout_height="match_parent"
+ vlc:overhangSize="60dp" >
<org.videolan.vlc.widget.ContentLinearLayout
android:layout_width="fill_parent"
@@ -46,7 +48,6 @@
<FrameLayout
android:id="@+id/audio_mini_player"
android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:minHeight="60dp" />
+ android:layout_height="fill_parent" />
</org.videolan.vlc.widget.SlidingPaneLayout>
\ No newline at end of file
diff --git a/vlc-android/res/values/attrs.xml b/vlc-android/res/values/attrs.xml
index ac21233..fd6d650 100644
--- a/vlc-android/res/values/attrs.xml
+++ b/vlc-android/res/values/attrs.xml
@@ -12,4 +12,8 @@
<attr name="orange" format="reference|color" />
<attr name="darkorange" format="reference|color" />
+ <declare-styleable name="SlidingPaneLayout">
+ <attr name="overhangSize" format="dimension" />
+ </declare-styleable>
+
</resources>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java b/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java
index 5cf4240..df3b9f6 100644
--- a/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java
+++ b/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java
@@ -24,6 +24,7 @@ package org.videolan.vlc.widget;
*/
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@@ -48,6 +49,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import org.videolan.vlc.R;
+
public class SlidingPaneLayout extends ViewGroup {
private static final String TAG = "VLC/SlidingPaneLayout";
@@ -151,8 +154,20 @@ public class SlidingPaneLayout extends ViewGroup {
public SlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ mOverhangSize = -1;
+
+ if (attrs != null) {
+ TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingPaneLayout);
+
+ if (ta != null)
+ mOverhangSize = ta.getDimensionPixelSize(R.styleable.SlidingPaneLayout_overhangSize, -1);
+ ta.recycle();
+ }
+
final float density = context.getResources().getDisplayMetrics().density;
- mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f);
+ if (mOverhangSize == -1) {
+ mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f);
+ }
setWillNotDraw(false);
@@ -402,10 +417,6 @@ public class SlidingPaneLayout extends ViewGroup {
int offset = 0;
if (lp.slideable) {
- int overhangSize = child.getMinimumHeight();
- if (overhangSize != 0)
- mOverhangSize = overhangSize;
-
final int margin = lp.topMargin + lp.bottomMargin;
final int range = Math.min(nextYStart, height - paddingBottom) - yStart - margin;
mSlideRange = range;
More information about the Android
mailing list