我对Android非常陌生,我打算将其发布到Android开发者 - Google网上论坛,但他们似乎说新手需要发布到Stack Overflow.所以我在这里
我昨天下载了最新版本的Android Studio 1.4.1,并按照构建您的第一个应用程序的说明进行操作.我做了一切,直到开始另一个活动.看起来这些说明有点旧,即对于以前版本的SDK,因为它们没有引用CoordinatorLayout
,AppBarLayout
但如果您按照步骤它们出现在代码中.显然,我确实对代码进行了微小的更改,以使这个应用程序正常工作,但并非完全如此.
我的问题:如果你看看Starting Another Activity底部的图像,你会发现它们都有My First App的标题.在我对代码的修改中,我无法在图像/屏幕上获得此标题.(我应该提一下,我想使用更新版本的AppBarLayout
和CoordinatorLayout
)
让我们专注于第一个屏幕,activity_my.xml
即
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
tools:context=".MyActivity">
<include layout="@layout/content_my" />
<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.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
正如构建简单用户界面底部所提到的content_my.xml
那样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)