第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Android studio Java - 地圖上的底部工作表視圖

Android studio Java - 地圖上的底部工作表視圖

慕田峪4524236 2023-08-16 18:05:41
對(duì)于android編程,java新手,我正在嘗試創(chuàng)建一個(gè)“簡(jiǎn)單..”BottomSheet,當(dāng)我單擊我的位置之一時(shí),它必須出現(xiàn)。實(shí)際上我已經(jīng)能夠創(chuàng)建我的地圖并加載我的點(diǎn)數(shù)據(jù)。我的地圖在一個(gè)片段中..    <?xml version="1.0" encoding="utf-8"?>    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"><fragment    android:id="@+id/map"    android:name="com.google.android.gms.maps.SupportMapFragment"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:clickable="true"    /></RelativeLayout>然后我查看在線教程創(chuàng)建了我的 BottomSheet。<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinaCoordinatorLayout        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"tools:context="com.chargesplit.android.activities.MainActivity"> <android.support.v4.widget.NestedScrollView    android:id="@+id/nestedScrollView"    android:layout_width="match_parent"    android:layout_height="300dp"    android:background="@android:color/holo_green_light"    android:clipToPadding="true"    app:behavior_hideable="true"    app:behavior_peekHeight="0dp"    app:layout_behavior="@string/bottom_sheet_behavior">    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical"        android:padding="16dp">    </LinearLayout></android.support.v4.widget.NestedScrollView></android.support.design.widget.CoordinaCoordinatorLayout>
查看完整描述

1 回答

?
炎炎設(shè)計(jì)

TA貢獻(xiàn)1808條經(jīng)驗(yàn) 獲得超4個(gè)贊

發(fā)生此錯(cuò)誤是因?yàn)槟幕顒?dòng)無(wú)法找到底部工作表視圖,為什么呢?因?yàn)槟牡撞抗ぷ鞅硪晥D未包含在activity_main.xml布局中。


換句話(huà)說(shuō),您MainActivity.java只能查看activity_main.xml,但它仍然不知道底部工作表的其他 xml 文件。


activity_main要解決此問(wèn)題:將布局中的代碼替換為


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

<android.support.design.widget.CoordinaCoordinatorLayout        

    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"

    tools:context="com.chargesplit.android.activities.MainActivity">


    <fragment

        android:id="@+id/map"

        android:name="com.google.android.gms.maps.SupportMapFragment"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:clickable="true"/>



     <android.support.v4.widget.NestedScrollView

        android:id="@+id/nestedScrollView"

        android:layout_width="match_parent"

        android:layout_height="300dp"

        android:background="@android:color/holo_green_light"

        android:clipToPadding="true"

        app:behavior_hideable="true"

        app:behavior_peekHeight="0dp"

        app:layout_behavior="@string/bottom_sheet_behavior">


        <LinearLayout

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:orientation="vertical"

            android:padding="16dp">


            <TextView

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:text="ciao"

                android:textColor="@android:color/white"

                android:textSize="24sp" />


            <TextView

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_marginTop="16dp"

                android:text="ciao2"

                android:textColor="@android:color/white" />

        </LinearLayout>


    </android.support.v4.widget.NestedScrollView>


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

注意:為了使您的布局看起來(lái)整潔,您可以將底部工作表視圖分離到一個(gè)單獨(dú)的布局中,這樣您就可以將其放入<android.support.v4.widget.NestedScrollView>bottom_sheet.xml中,然后從activity_main.xml中引用它


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

希望對(duì)您有所幫助。如果您需要進(jìn)一步的幫助,請(qǐng)告訴我


查看完整回答
反對(duì) 回復(fù) 2023-08-16
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)