gpt4 book ai didi

java - 谷歌 i/o 应用程序 : where it sets toolbar_actionbar

转载 作者:行者123 更新时间:2023-11-29 09:29:34 25 4
gpt4 key购买 nike

我正在尝试研究 Google i/o 2014 的应用。

BaseActivity里面它有这个方法:

protected Toolbar getActionBarToolbar() {
if (mActionBarToolbar == null) {
mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
if (mActionBarToolbar != null) {
setSupportActionBar(mActionBarToolbar);
}
}
return mActionBarToolbar;
}

为什么 findViewById 不返回 null? :/

WelcomeActivity 的内容 View 这样做:setContentView(R.layout.activity_welcome); 这是 activity_welcome.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:iosched="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.WelcomeActivity">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#e5e5e5">

<ImageView
android:src="@drawable/io2014_logo"
android:layout_width="200dp"
android:layout_height="100dp"
android:scaleType="fitCenter"
android:tint="#7000"
android:layout_gravity="center|top" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="100dp"
android:clipToPadding="false">

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
iosched:cardBackgroundColor="#fff"
iosched:cardCornerRadius="@dimen/card_corner_radius"
iosched:cardElevation="@dimen/card_elevation"
iosched:cardPreventCornerOverlap="false">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@string/font_fontFamily_medium"
android:text="@string/welcome_to_google_i_o_app"
android:textColor="@color/theme_primary"
android:textSize="@dimen/text_size_xlarge"
android:textStyle="@integer/font_textStyle_medium" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:autoLink="web"
android:text="@string/welcome_text"
android:textColor="@color/body_text_2"
android:textSize="@dimen/text_size_medium" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:autoLink="web"
android:text="@string/eula_legal_text"
android:textColor="@color/body_text_2"
android:textSize="@dimen/text_size_medium" />

</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
</ScrollView>

</FrameLayout>

<!-- Button bar -->
<LinearLayout
android:layout_height="48dp"
android:background="@color/theme_primary"
android:layout_gravity="bottom"
android:layout_width="match_parent">

<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="?photoItemForeground"
android:text="@string/decline"
android:textColor="#8fff"
android:textSize="@dimen/text_size_medium"
android:textStyle="@integer/font_textStyle_medium"
android:fontFamily="@string/font_fontFamily_medium"
android:textAllCaps="true"
android:id="@+id/button_decline" />

<Button
android:id="@+id/button_accept"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="?photoItemForeground"
android:text="@string/accept"
android:textSize="@dimen/text_size_medium"
android:textStyle="@integer/font_textStyle_medium"
android:fontFamily="@string/font_fontFamily_medium"
android:textAllCaps="true"
android:textColor="#fff" />

</LinearLayout>
</LinearLayout>

所以它不以任何方式包括 toolbar_actionbar.xml .我还查看了 style.xml 中的一些提示(也许它以某种方式包含在所有文件中)但我真的找不到任何东西。

感谢帮助

最佳答案

事情是这样的:

1) WelcomeActivity不从 BaseActivity 延伸, 所以 getActionBarToolbar()在这种情况下不会被调用。

2) ActivitiesBaseActivity 的子类有<include layout="@layout/toolbar_actionbar" />在他们的 View 层次结构中的某个地方。

关于java - 谷歌 i/o 应用程序 : where it sets toolbar_actionbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27581963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com