小编sta*_*pot的帖子

如何在LinearLayout中包装协调器布局?

我试图在另一个布局中使用新的Android Design Library的CoordinatorLayout.CoordinatorLayout包含RecyclerView.我试图做的是在CoordinatorLayout下面放置一个简单的LinearLayout.此布局应放在CoordinatorLayout下方.这是我使用的XML:

<LinearLayout 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"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary" />

        </android.support.design.widget.AppBarLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/conversation_recyclerview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    </android.support.design.widget.CoordinatorLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:orientation="horizontal">

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="match_parent" />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/ic_send_white_36dp" />

    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

如您所见,我试图将CoordinatorLayout包装在另一个LinearLayout中.但是,在屏幕上,布局的第二部分甚至无法渲染.

android android-layout coordinator-layout

4
推荐指数
1
解决办法
1万
查看次数

无法创建 Android 管理注册 URL

我正在尝试为我们的组织访问新的 Android Management API,但在访问 API 时遇到问题。通过 API 浏览器访问 API 时,一切运行正常。为了在我们的服务器上运行它,我在 Google 云控制台中创建了一个新项目,并在那里创建了一个服务帐户。我下载了密钥并使用它在我的机器上进行本地测试。然而,在第一次 signupUrl 调用时,我收到 403 错误,指出:“调用者无权管理项目。”。我正在使用的服务帐户具有“项目所有者”角色,我不知道如何赋予它更多权限......

我正在使用的代码:

def initial_enterprise_user(request):
    enterprise_token = request.GET.get('enterpriseToken')
    usr = request.user

    scopes = ['https://www.googleapis.com/auth/androidmanagement']

    credentials = ServiceAccountCredentials.from_json_keyfile_name(settings.SERVICE_ACCOUNT, scopes=scopes)

    if enterprise_token is None:
        androidmanagement = build('androidmanagement', 'v1', credentials=credentials)
        resp = androidmanagement.signupUrls().create(projectId=settings.ANDROID_MGMT_PROJECTID).execute()
        if resp.status_code == 200:
            usr.signup_url_name = resp.json()['name']
            usr.save()
            return render(request, 'initial_login.html', {'response_url': resp.json()['url']})
        else:
            return HttpResponse('Failed to get signup url')
    else:
        # handle token present
Run Code Online (Sandbox Code Playgroud)

python mdm android-for-work cosu android-management-api

4
推荐指数
1
解决办法
1269
查看次数