android - Use a resource ( progressbar ) in multiple layouts -
so of layouts have same base structure:
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" style="@android:style/textappearance.devicedefault.medium" xmlns:autofit="http://schemas.android.com/apk/res-auto"> <progressbar android:id="@+id/upperloading" style="?android:attr/progressbarstyle" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginbottom="8dp" android:layout_margintop="20dp" android:elevation="17dp" android:visibility="invisible" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" app:layout_constraintvertical_bias="0.007" tools:layout_constraintleft_creator="1" tools:layout_constraintright_creator="1" tools:layout_constrainttop_creator="1" tools:layout_editor_absolutex="163dp" /> <progressbar android:id="@+id/mainloading" style="?android:attr/progressbarstyle" android:layout_width="100dp" android:layout_height="100dp" android:layout_marginbottom="8dp" android:layout_margintop="142dp" android:visibility="invisible" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="@+id/dashboardscrollview" app:layout_constraintvertical_bias="0.0" tools:layout_constraintleft_creator="1" tools:layout_constraintright_creator="1" tools:layout_constrainttop_creator="1" /> <scrollview android:id="@+id/dashboardscrollview" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginend="1dp" android:layout_marginleft="1dp" android:layout_marginright="1dp" android:layout_marginstart="1dp" android:layout_margintop="70dp" app:layout_constraintbottom_tobottomof="parent" app:layout_constrainthorizontal_bias="0.0" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" tools:layout_constraintleft_creator="1" tools:layout_constraintright_creator="1" tools:layout_constrainttop_creator="1"> //content </scrollview> </android.support.constraint.constraintlayout>
i using progressbars changing visibility in java whenever make request. how can define upperloading , mainloading , reuse them in multiple layouts? new android sorry if question simple.
you can create new layout reusable views , use <include />
tag add layout.xml
see here more information: https://developer.android.com/training/improving-layouts/reusing-layouts.html
Comments
Post a Comment