Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

视图全局配置 #23

Closed
wbaizx opened this issue Oct 31, 2018 · 5 comments
Closed

视图全局配置 #23

wbaizx opened this issue Oct 31, 2018 · 5 comments

Comments

@wbaizx
Copy link

wbaizx commented Oct 31, 2018

对于整个app都公用同样一套布局的时候,可以增加一个全局配置布局的方法,app加载时一次性配置

@qyxxjd
Copy link
Owner

qyxxjd commented Nov 7, 2018

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

@VanConsday
Copy link

道理明白,码不出- -

@wbaizx
Copy link
Author

wbaizx commented Nov 8, 2018

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

@qyxxjd
Copy link
Owner

qyxxjd commented Nov 13, 2018

自定义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 加载内容

@CysionLiu
Copy link

CysionLiu commented Dec 27, 2018

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

@qyxxjd qyxxjd closed this as completed Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants