Android的工作室 - 无法拖放按钮 [英] Android Studio - Cannot Drag and Drop Button

查看:231
本文介绍了Android的工作室 - 无法拖放按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个新的项目,空白的活动。如果我进入了activity_main.xml中的接口,我不能拖放任何部件。我试图改变主题,仍然一无所获。这是我的activity_main.xml中和清单文件。

I just created a new project, blank activity. If I go into the interface for the activity_main.xml I cannot drag and drop any widgets. I tried changing the theme, still nothing. Here is my activity_main.xml and manifest files.

清单:

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

activity_main.xml中:

activity_main.xml:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

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

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

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

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_dialog_email" />

推荐答案

Android的工作室改变了布局 activity_main.xml中并使其像的东西的容器 FloatingActionButton 工具栏 ..所以你不能拖放按钮那里。他们创建了一个名为 content_main.xml 在这里你可以添加其他所有视图另一个XML文件。它们包括内部activity_main的content_main通过

Android Studio changed the layout activity_main.xml and made it as a container for things like FloatingActionButton, ToolBar.. so you can't drag and drop buttons there. They created another xml file called content_main.xml where you can add all your other views. They include the content_main inside activity_main by

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

这篇关于Android的工作室 - 无法拖放按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆