Android组织布局资源

Android组织布局资源

本文介绍了Android组织布局资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试组织布局资源.

I'm trying to organizing layout resource.

以下内容: -分辨率/布局 -资源/布局/活动 -分辨率/布局/片段
-res/layouts/other

Following: - res/layouts - res/layouts/activities - res/layouts/fragments
- res/layouts/other

但是我的荣幸只是创建了活动"目录.

But my gradle is only creating "activities" directory.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.khash.viewpagerexample"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main{
            res.srcDirs = [
                    'src/main/res/layouts/activities',
                    'src/main/res/layouts',
                    'src/main/res/layouts/fragments',
                    'src/main/res/layouts',
                    'src/main/res'
            ]
        }
    }
    }

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:26.0.0-alpha1'
}

我如何将所有(活动,片段,其他,主要)目录添加到res.

How i can add all(activities, fragment , other, main) directory to res.

推荐答案

尝试一下:

  1. 更改android->项目

  1. Change android -> Project

重命名布局->布局

在布局中创建新目录,将其命名为活动和片段.(此文件夹名称与gradle同步.使用与gradle中使用的名称相同.)

Create new directory inside layouts named it as activities and fragments.(this folder names is sync with gradle. use same name as used in gradle.)

在布局中创建的每个目录中创建布局目录.

Create layout directory in each directory you have created in layouts.

根据需要将xml放入目录中.

Put your xmls as you want in your directory.

成绩文件:build.gradle(app)

sourceSets {
            main {
                res.srcDirs =
                        [
                                'src/main/res/layouts/activities',
                                'src/main/res/layouts/fragments',
                                'src/main/res/layouts',
                                'src/main/res'
                        ]
            }
        }

这篇关于Android组织布局资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:01