CustomViews este se crea heredando desde View
Recordatorio: View es el elemento principal para renderizar dentro de una pantalla
Arquitectura
Qu茅 aprender谩s sobre patrones de dise帽o en android
驴Qu茅 es arquitectura?
Tipos de arquitectura en Android
Presentaci贸n del proyecto: Platzi Wallet
Patr贸n de arquitectura MVP
Implementaci贸n de MVP en el proyecto
Comunicaci贸n entre capas MVP
Creaci贸n del loader y resultados de la implementaci贸n
Patr贸n de arquitectura MVVM
Patrones de dise帽o
Qu茅 es un patr贸n de dise帽o y qu茅 tipos existen
Patrones de dise帽o creacionales
Singleton
Object Singleton
驴Qu茅 es Builder?
Aplicando builder en c贸digo
Funci贸n Apply en Builder
Factory
Patrones de dise帽o estructurales
Adapter
Proxy
Facade
Patrones de comportamiento
Observer
C贸mo implementar observer en el proyecto
Command
C贸mo implementar command en el proyecto
Prueba de ejecuci贸n de comandos
Bonus: Architecture Components
Introducci贸n a Architecture Components
LiveData
Introducci贸n a Room y preparaci贸n del proyecto
Creaci贸n de componentes de Room
Comunicaci贸n entre componentes
ViewModel
Bonus: Custom View
Creando Custom Views
Conclusiones
Conclusiones y consejos para seguir aprendiendo
You don't have access to this class
Keep learning! Join and start boosting your career
Creating efficient and manageable applications is essential in mobile development. Duplication of code not only fragments our application; it also complicates maintenance and future adaptation. To solve this, it is possible to create "custom views" that allow us to reuse code and make changes in a simple and global way.
A custom view is created from the View
class, which is fundamental to render elements on screen. This custom view could include, as in our example, a TextView
and a CircularProgressbar
.
View
.Context
.Context
and AttributeSet
.Context
, AttributeSet
and int
defStyle.initView()
to configure the view each time a constructor is initialized.public class PresentasView extends View { public PresentasView(Context context) { super(context); initView(); }
public PresentasView(Context context, AttributeSet attrs) { super(context, attrs); initView();
}
public PresentasView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); initView(); }
private void initView() { // Initialization of components } }}
The layout elements must be inflated and added to the appropriate container, using FrameLayout
which allows you to add views easily. By following these steps you can configure the view:
LayoutInflater
to inflate the XML of the layout.addView()
to add views to FrameLayout
.private void initView() { LayoutInflater inflater = LayoutInflater.from(getContext()); View view view = inflater.inflate(R.layout.my_custom_view, this, false); addView(view);}
To include the custom view in your XML layouts, simply declare the new custom view
as you would a standard widget. Define sizes and positions as needed.
<your.package.PresentasView android:layout_width="200dp" android:layout_height="200dp" android:layout_gravity="center" />
Benefits:
Challenges:
Finally, the development and use of custom views not only make the application more efficient, but are also a powerful tool to ensure that any changes to your components are propagated accurately and effectively in your application. It's your turn to experiment and implement this technique!
Contributions 3
Questions 0
CustomViews este se crea heredando desde View
Recordatorio: View es el elemento principal para renderizar dentro de una pantalla
Como puedo hacer que se vea reflejado en los dos activitys el progres ?, hablo del reto
En los observadores no se debe eliminar , si no llamar al customVIew
homePresenter.getPercentageLiveData().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
percentageValue -> circularProgress.percentageText.text = percentageValue
})
Want to see more contributions, questions and answers from the community?