Introducing the AndroidDynamicLayoutLoader library, a powerful solution for seamlessly inflating dynamic layouts at runtime using JSON configurations obtained from a server. This library proves invaluable in scenarios where layouts require modification without the need for updating the entire application.
By leveraging the DynamicLayoutLoader library, developers can effortlessly adapt their app’s UI in real-time, ensuring a dynamic user experience. With the ability to fetch JSON configurations from a server, it becomes a breeze to incorporate layout changes on-the-fly without necessitating a full app update.
Stay ahead of the curve with this groundbreaking Android library, enabling you to effortlessly handle ever-changing layout requirements. Experience the ease and flexibility of runtime layout inflation, powered by the DynamicLayoutLoader library.
Some of Designs
Results | Login Screen |
---|---|
build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
implementation 'com.github.vvsdevs:AndroidDynamicLayoutLoader:v1.0.0'
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
{
"views":[
{
"class":"android.widget.ImageView",
"attributes":{
"layout_width":"wrap_content",
"layout_height":"wrap_content",
"src":"https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
"cache":true
}
},
{
"class":"android.widget.TextView",
"attributes":{
"text":"Yo!",
"textColor":"#FF69B4"
}
}
]
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mainLayout">
<!-- Dynamic content will be added here -->
</LinearLayout>
try {
new LayoutUpdater("https://raw.githubusercontent.com/vvsdevs/AndroidDynamicLayoutLoader/master/DemoLayout/src/main/assets/",
"login_screen",
findViewById(R.id.mainLayout))
.initialize();
}
catch (DynamicException e) {
e.printStackTrace();
}
For advanced usage, take a look at this awesome manual.
setListener(new LayoutStateListener() {
@Override
public void onSuccess(String message) {
// everything is okay
}
@Override
public void onError(String message) {
// notify user
}
})
setOptions(CACHE_ONLY)
setOptions(NON_STOP) // use with setAsyncPause(long millis)
public DynamicLayoutLoader(String url, String name, ViewGroup layout) throws DynamicLayoutLoaderException
One and only constructor
url
— URL of directory/folder where JSON layout file is located (for example, “https://raw.githubusercontent.com/vvsdevs/AndroidDynamicLayoutLoader/master/DemoLayout/src/main/assets/”)name
— JSON layout file name with or without extension (for example, “login_screen”) (* Don’t add example. “login_screen.json”)layout
— wrapper layout that will contain inflated layout from JSON file (for example, findViewById(R.id.mainLayout))DynamicLayoutLoaderException
— if any of passed parameters is nullpublic DynamicLayoutLoader setListener(DynamicLayoutLoaderListener listener)
Attaches event listener to DynamicLayoutLoader object
listener
— listener for success and error events caused by network, storage, etc.public DynamicLayoutLoader setOptions(DynamicLayoutLoaderOptions.Option ... options)
Attaches options to DynamicLayoutLoader object
options
— options for DynamicLayoutLoader (for example, ONLY_CACHE)public void initialize()
Starts layout fetching from cache/server depending on provided options