Code Monkey home page Code Monkey logo

Comments (5)

qyxxjd avatar qyxxjd commented on June 26, 2024

抽象一个 common_layout.xml 文件,使用的地方动态设置内容布局即可

from multiplestatusview.

VanConsday avatar VanConsday commented on June 26, 2024

道理明白,码不出- -

from multiplestatusview.

wbaizx avatar wbaizx commented on June 26, 2024

抽象xml文件是啥意思?我的意思是说,可不可以在Application中用静态方法配置默认几个布局,这样,每个地方就不用再动态配置了 0.0

from multiplestatusview.

qyxxjd avatar qyxxjd commented on June 26, 2024

自定义View都属于局部的,没有全局的概念,你说的场景可以参考下面的示例方案:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/toolbar"/>

    <com.classic.common.MultipleStatusView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="?attr/actionBarSize"
        app:emptyView="@layout/custom_empty_view"
        app:errorView="@layout/custom_error_view"
        app:loadingView="@layout/custom_loading_view"
        app:noNetworkView="@layout/custom_no_network_view">

        <FrameLayout
            android:id="you_content_view_id"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </com.classic.common.MultipleStatusView>
</FrameLayout>

然后有一个抽象的ActivityFragment动态通过 you_content_view_id 加载内容

from multiplestatusview.

CysionLiu avatar CysionLiu commented on June 26, 2024

鉴于资源覆盖的特性,在依赖本库的module中,或者作为appliaction的module中,分别创建几个布局文件,这里共4个,即:loading_view.xml 、 empty_view.xml 、error_view.xml以及no_network_view.xml ; 注意: 名字和【关键view的id】一定要与本库内部的相同,其它的样式根据自己项目来,即可实现全局配置。

from multiplestatusview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.