SlideShare a Scribd company logo
1 of 20
Download to read offline
VIEW CUSTOMIZATION
IN A NUTSHELL
@bernhardpflug
plus.google.com/+BernhardPflug
Iconmobile
170
Headquarter
BMW
BMW remote apps
The app
UX Don’t just start coding
Make it easy to
send feedback
Analyse usage
One UX example
Custom view drawing with animation
public class TankView extends ViewGroup {
!
. . .
!
private void updateBoilerAppearance() {
. . .
liquidPaths[i] = new Path();

liquidPaints[i] = new Paint(liquidPaint);



liquidPaints[i].setShader(new LinearGradient(. . .}, new float[] { . . . },
Shader.TileMode.CLAMP));
!
liquidPaths[i].moveTo(. . .);
liquidPaths[i].lineTo(. . .);
liquidPaths[i].quadTo(. . .);

. . .
!
liquidPathEffects[i].add(new DashPathEffect(new float[] { . . . ));
!
}
!
. . .
}
!
!
!
@Override

protected void dispatchDraw(Canvas canvas) {



canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), alpha,
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);



canvas.drawPath(boilerContour, contourPaint);


. . .


if (state == State.HEATING) {

// draw pipe

canvas.drawRect(pipeBounds, fillPaint);

canvas.drawLine(. . . );

canvas.drawLine(. . . );



// draw liquid

for (int i = 0; i < liquidPaths.length; i++) {

canvas.drawPath(liquidPaths[i], liquidPaints[i]);

}



liquidAnimHandler.postDelayed(liquidAnimation, 50);

}

}
Custom view drawing with animation
@Override

protected void onSizeChanged(int w, int h, int oldw, int oldh) {



updateBoilerAppearance();

super.onSizeChanged(w, h, oldw, oldh);

}
Custom view drawing with animation
public class SvgView extends View {
!
. . .
!
@Override

protected void onSizeChanged(int w, int h, int oldw, int oldh) {

super.onSizeChanged(w, h, oldw, oldh);



if (w > 0 && h > 0 && svg != null) {

svg.setDocumentWidth(w);

svg.setDocumentHeight(h);

Bitmap svgBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);

Canvas bitmapCanvas = new Canvas(svgBitmap);

// Render our document onto our canvas

svg.renderToCanvas(bitmapCanvas);

setBackgroundDrawable(new BitmapDrawable(getResources(), svgBitmap));

}

}
!
. . .
}
Consider SVG instead of dpi graphics
{} @ github.com/bernhardpflug/AndroidUtilities
Custom swipe component
Custom swipe component
Ground View
Sky View
public class VerticalViewPager extends ViewGroup {
. . .
!
@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {



int width = getDefaultSize(0, widthMeasureSpec);

int height = getDefaultSize(0, heightMeasureSpec);

setMeasuredDimension(width, height);



int hPadding = getPaddingLeft()+getPaddingRight();

int vPadding = getPaddingTop()+getPaddingBottom();



int contentWidth = getChildMeasureSpec(widthMeasureSpec, hPadding , width);

int contentHeight = getChildMeasureSpec(heightMeasureSpec,vPadding , height);


groundView.measure(contentWidth, contentHeight);



int skyViewHeight = skyView.getLayoutParams().height;

int skyHeight = getChildMeasureSpec(heightMeasureSpec, vPadding, skyViewHeight);

skyView.measure(contentWidth, skyHeight);


}
!
. . .
!
}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities
Ground View
Sky View
@Override

protected void onLayout(boolean changed, int l, int t, int r, int b) {

final int width = r - l;

final int height = b - t;



int skyViewHeight = skyView.getMeasuredHeight();

skyView.layout(0, 0, width, skyView.getMeasuredHeight());

groundView.layout(0, skyViewHeight, width, height + skyViewHeight);


}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities
Ground View
Sky View
@Override

public boolean onTouchEvent(MotionEvent event) {
!
. . .
!
switch (event.getAction()) {

. . .



case MotionEvent.ACTION_MOVE:
!
int touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();




if (!verticalScrolling && Math.abs(deltaY) > touchSlop) {

verticalScrolling = true;



requestDisallowInterceptTouchEvent(true);
!
if (getScrollY() + deltaY <= State.CLOSED && getScrollY() + deltaY >= State.OPEN)
{

scrollBy(0, (int) deltaY);



}


}
!
!
}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities
@Override

public boolean onTouchEvent(MotionEvent event) {
!
. . .
!
switch (event.getAction()) {

. . .



case MotionEvent.ACTION_UP:



scroller.startScroll(0, getScrollY(), 0, getY(destinationState) - getScrollY());


break;
!
!
}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities
@Override

public void computeScroll() {

if (scroller.computeScrollOffset()) {



int x = scroller.getCurrX();

int y = scroller.getCurrY();



scrollTo(x, y);



postInvalidate();

}
}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities
at.bernhardpflug.heating
Give it a try
Google Play
{} @ github.com/bernhardpflug/AndroidUtilities
Thank you!
plus.google.com/+BernhardPflug
@bernhardpflug

More Related Content

Viewers also liked

Viewers also liked (13)

Knock knock on GameDev gateway! - Introduction to Game development
Knock knock on GameDev gateway! - Introduction to Game developmentKnock knock on GameDev gateway! - Introduction to Game development
Knock knock on GameDev gateway! - Introduction to Game development
 
Web Server Load Balancing
Web Server Load BalancingWeb Server Load Balancing
Web Server Load Balancing
 
[MBF2] APIs Deezer par Cédric Pascal & Louis Cheynel
[MBF2] APIs Deezer par Cédric Pascal & Louis Cheynel[MBF2] APIs Deezer par Cédric Pascal & Louis Cheynel
[MBF2] APIs Deezer par Cédric Pascal & Louis Cheynel
 
Deloitte UK / Facebook : a people based telecom business - breathing new lif...
Deloitte UK / Facebook  : a people based telecom business - breathing new lif...Deloitte UK / Facebook  : a people based telecom business - breathing new lif...
Deloitte UK / Facebook : a people based telecom business - breathing new lif...
 
[MBF2] Webinar plate-forme Salesforce #1
[MBF2] Webinar plate-forme Salesforce #1[MBF2] Webinar plate-forme Salesforce #1
[MBF2] Webinar plate-forme Salesforce #1
 
“Les Français et les Campagnes «Santé»” Enquête Future Thinking / FNAIM - Fév...
“Les Français et les Campagnes «Santé»” Enquête Future Thinking / FNAIM - Fév...“Les Français et les Campagnes «Santé»” Enquête Future Thinking / FNAIM - Fév...
“Les Français et les Campagnes «Santé»” Enquête Future Thinking / FNAIM - Fév...
 
[Ultracode Munich Meetup #9] From Sand to Silicon by Christian Anderka
[Ultracode Munich Meetup #9] From Sand to Silicon by Christian Anderka[Ultracode Munich Meetup #9] From Sand to Silicon by Christian Anderka
[Ultracode Munich Meetup #9] From Sand to Silicon by Christian Anderka
 
L'oculus rift de a à z meetup unity
L'oculus rift de a à z   meetup unityL'oculus rift de a à z   meetup unity
L'oculus rift de a à z meetup unity
 
HP Helion European Webinar Series ,Webinar #3
HP Helion European Webinar Series ,Webinar #3 HP Helion European Webinar Series ,Webinar #3
HP Helion European Webinar Series ,Webinar #3
 
HP Helion Webinar #2
HP Helion Webinar #2 HP Helion Webinar #2
HP Helion Webinar #2
 
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian FrankHP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
 
[MirrorLink Hackathon] Introduction Slideshow by Alexandre Sutra
[MirrorLink Hackathon] Introduction Slideshow by Alexandre Sutra[MirrorLink Hackathon] Introduction Slideshow by Alexandre Sutra
[MirrorLink Hackathon] Introduction Slideshow by Alexandre Sutra
 
Augmented Reality (AR) in Education
Augmented Reality (AR) in EducationAugmented Reality (AR) in Education
Augmented Reality (AR) in Education
 

Similar to [Ultracode Munich Meetup #7] Android view customization in a nutshell

Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views
Lars Vogel
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
Bitla Software
 
Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011
Johan Nilsson
 
Creating custom views
Creating custom viewsCreating custom views
Creating custom views
Mu Chun Wang
 

Similar to [Ultracode Munich Meetup #7] Android view customization in a nutshell (20)

Creating an Uber Clone - Part XXIV - Transcript.pdf
Creating an Uber Clone - Part XXIV - Transcript.pdfCreating an Uber Clone - Part XXIV - Transcript.pdf
Creating an Uber Clone - Part XXIV - Transcript.pdf
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views
 
I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)
 
Prototype UI
Prototype UIPrototype UI
Prototype UI
 
Android Wear Essentials
Android Wear EssentialsAndroid Wear Essentials
Android Wear Essentials
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?
 
Responsive layouts by Maqbool
Responsive layouts by MaqboolResponsive layouts by Maqbool
Responsive layouts by Maqbool
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animations
 
Canvas al ajillo
Canvas al ajilloCanvas al ajillo
Canvas al ajillo
 
Sperimentazioni lezione6 from_designtoapplication copy
Sperimentazioni lezione6 from_designtoapplication copySperimentazioni lezione6 from_designtoapplication copy
Sperimentazioni lezione6 from_designtoapplication copy
 
Prototype UI Intro
Prototype UI IntroPrototype UI Intro
Prototype UI Intro
 
Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011
 
Manual Layout Revisited
Manual Layout RevisitedManual Layout Revisited
Manual Layout Revisited
 
Android accessibility for developers and QA
Android accessibility for developers and QAAndroid accessibility for developers and QA
Android accessibility for developers and QA
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 Canvas
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
Android query
Android queryAndroid query
Android query
 
Creating custom views
Creating custom viewsCreating custom views
Creating custom views
 
Android development for iOS developers
Android development for iOS developersAndroid development for iOS developers
Android development for iOS developers
 

More from BeMyApp

Présentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM WatsonPrésentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM Watson
BeMyApp
 

More from BeMyApp (20)

Introduction to epid
Introduction to epidIntroduction to epid
Introduction to epid
 
Introduction ciot workshop premeetup
Introduction ciot workshop premeetupIntroduction ciot workshop premeetup
Introduction ciot workshop premeetup
 
Présentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM WatsonPrésentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM Watson
 
Crédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et ParcoursCrédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et Parcours
 
Cisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - IntroCisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - Intro
 
Tumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensembleTumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensemble
 
Building your first game in Unity 3d by Sarah Sexton
Building your first game in Unity 3d  by Sarah SextonBuilding your first game in Unity 3d  by Sarah Sexton
Building your first game in Unity 3d by Sarah Sexton
 
Using intel's real sense to create games with natural user interfaces justi...
Using intel's real sense to create games with natural user interfaces   justi...Using intel's real sense to create games with natural user interfaces   justi...
Using intel's real sense to create games with natural user interfaces justi...
 
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon CollinsIntroduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
 
Audio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchAudio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy Touch
 
Shaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the BestShaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the Best
 
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
 
Tools to Save Time
Tools to Save TimeTools to Save Time
Tools to Save Time
 
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
 
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
 
[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technology[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technology
 
HP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit RecapHP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit Recap
 
Webinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco MarcellinoWebinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco Marcellino
 
HP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond FirewallsHP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond Firewalls
 
HP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pillHP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pill
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 

[Ultracode Munich Meetup #7] Android view customization in a nutshell

  • 6. UX Don’t just start coding Make it easy to send feedback Analyse usage
  • 8. Custom view drawing with animation public class TankView extends ViewGroup { ! . . . ! private void updateBoilerAppearance() { . . . liquidPaths[i] = new Path();
 liquidPaints[i] = new Paint(liquidPaint);
 
 liquidPaints[i].setShader(new LinearGradient(. . .}, new float[] { . . . }, Shader.TileMode.CLAMP)); ! liquidPaths[i].moveTo(. . .); liquidPaths[i].lineTo(. . .); liquidPaths[i].quadTo(. . .);
 . . . ! liquidPathEffects[i].add(new DashPathEffect(new float[] { . . . )); ! } ! . . . } ! !
  • 9. ! @Override
 protected void dispatchDraw(Canvas canvas) {
 
 canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), alpha, Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
 
 canvas.drawPath(boilerContour, contourPaint); 
 . . . 
 if (state == State.HEATING) {
 // draw pipe
 canvas.drawRect(pipeBounds, fillPaint);
 canvas.drawLine(. . . );
 canvas.drawLine(. . . );
 
 // draw liquid
 for (int i = 0; i < liquidPaths.length; i++) {
 canvas.drawPath(liquidPaths[i], liquidPaints[i]);
 }
 
 liquidAnimHandler.postDelayed(liquidAnimation, 50);
 }
 } Custom view drawing with animation
  • 10. @Override
 protected void onSizeChanged(int w, int h, int oldw, int oldh) {
 
 updateBoilerAppearance();
 super.onSizeChanged(w, h, oldw, oldh);
 } Custom view drawing with animation
  • 11. public class SvgView extends View { ! . . . ! @Override
 protected void onSizeChanged(int w, int h, int oldw, int oldh) {
 super.onSizeChanged(w, h, oldw, oldh);
 
 if (w > 0 && h > 0 && svg != null) {
 svg.setDocumentWidth(w);
 svg.setDocumentHeight(h);
 Bitmap svgBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
 Canvas bitmapCanvas = new Canvas(svgBitmap);
 // Render our document onto our canvas
 svg.renderToCanvas(bitmapCanvas);
 setBackgroundDrawable(new BitmapDrawable(getResources(), svgBitmap));
 }
 } ! . . . } Consider SVG instead of dpi graphics {} @ github.com/bernhardpflug/AndroidUtilities
  • 14. public class VerticalViewPager extends ViewGroup { . . . ! @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
 
 int width = getDefaultSize(0, widthMeasureSpec);
 int height = getDefaultSize(0, heightMeasureSpec);
 setMeasuredDimension(width, height);
 
 int hPadding = getPaddingLeft()+getPaddingRight();
 int vPadding = getPaddingTop()+getPaddingBottom();
 
 int contentWidth = getChildMeasureSpec(widthMeasureSpec, hPadding , width);
 int contentHeight = getChildMeasureSpec(heightMeasureSpec,vPadding , height); 
 groundView.measure(contentWidth, contentHeight);
 
 int skyViewHeight = skyView.getLayoutParams().height;
 int skyHeight = getChildMeasureSpec(heightMeasureSpec, vPadding, skyViewHeight);
 skyView.measure(contentWidth, skyHeight); 
 } ! . . . ! } Implementing custom swipe components {} @ github.com/bernhardpflug/AndroidUtilities Ground View Sky View
  • 15. @Override
 protected void onLayout(boolean changed, int l, int t, int r, int b) {
 final int width = r - l;
 final int height = b - t;
 
 int skyViewHeight = skyView.getMeasuredHeight();
 skyView.layout(0, 0, width, skyView.getMeasuredHeight());
 groundView.layout(0, skyViewHeight, width, height + skyViewHeight); 
 } Implementing custom swipe components {} @ github.com/bernhardpflug/AndroidUtilities Ground View Sky View
  • 16. @Override
 public boolean onTouchEvent(MotionEvent event) { ! . . . ! switch (event.getAction()) {
 . . .
 
 case MotionEvent.ACTION_MOVE: ! int touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); 
 
 if (!verticalScrolling && Math.abs(deltaY) > touchSlop) {
 verticalScrolling = true;
 
 requestDisallowInterceptTouchEvent(true); ! if (getScrollY() + deltaY <= State.CLOSED && getScrollY() + deltaY >= State.OPEN) {
 scrollBy(0, (int) deltaY);
 
 } 
 } ! ! } Implementing custom swipe components {} @ github.com/bernhardpflug/AndroidUtilities
  • 17. @Override
 public boolean onTouchEvent(MotionEvent event) { ! . . . ! switch (event.getAction()) {
 . . .
 
 case MotionEvent.ACTION_UP:
 
 scroller.startScroll(0, getScrollY(), 0, getY(destinationState) - getScrollY()); 
 break; ! ! } Implementing custom swipe components {} @ github.com/bernhardpflug/AndroidUtilities
  • 18. @Override
 public void computeScroll() {
 if (scroller.computeScrollOffset()) {
 
 int x = scroller.getCurrX();
 int y = scroller.getCurrY();
 
 scrollTo(x, y);
 
 postInvalidate();
 } } Implementing custom swipe components {} @ github.com/bernhardpflug/AndroidUtilities
  • 19. at.bernhardpflug.heating Give it a try Google Play {} @ github.com/bernhardpflug/AndroidUtilities