Android Studio 相同的菜单布局在我的活动中看起来不同

问题描述

我的应用程序中有一个菜单,它在我的所有活动中看起来都一样,除了一个。我不知道为什么它在那个活动中看起来不同(它是一个包含片段的谷歌地图活动)

我在应用中使用的菜单代码以及菜单在整个应用中的外观:click to see how the menu normally looks like

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#Ffdb78"
    style="@style/Theme.BudgetApplicationBadeaPatricia"
    tools:context=".Activities.MainActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:id="@+id/linearlayouthome"
        android:gravity="center"
        android:layout_marginTop="50dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="Welcome,"
            android:textColor="#474747"
            android:textSize="25sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tvSetTextUsernameHome"
            android:layout_width="wrap_content"
            android:layout_height="45dp"
            android:paddingLeft="10dp"
            android:text=""
            android:textColor="#474747"
            android:textSize="25sp"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearlayoutyourbalance"
        android:layout_width="341dp"
        android:layout_height="125dp"
        android:layout_below="@id/linearlayouthome"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/shape"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/imgPiggy"
            android:layout_width="120dp"
            android:layout_height="match_parent"
            android:layout_below="@id/linearlayouthome"
            android:layout_margin="5dp"
            android:scaleType="fitStart"
            android:src="@drawable/pig" />

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

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:text="Your budget is :"
                android:textColor="#474747"
                android:textAlignment="center"
                android:layout_gravity="center"
                android:textSize="25sp"
                android:textStyle="bold" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/tvBudgetMainHome"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:textColor="#474747"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/tvCurrencyMain"
                    android:layout_width="match_parent"
                    android:layout_height="30dp"
                    android:text="RON"
                    android:textColor="#474747"
                    android:textSize="20sp"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:orientation="horizontal">

                <androidx.appcompat.widget.AppCompatButton
                    android:id="@+id/btnAddBudget"
                    android:layout_width="60dp"
                    android:layout_height="30dp"
                    android:layout_marginRight="20dp"
                    android:background="@drawable/button"
                    android:text="+"
                    android:textColor="@color/black" />

                <androidx.appcompat.widget.AppCompatButton
                    android:id="@+id/btnSubstractBudget"
                    android:layout_width="60dp"
                    android:layout_height="30dp"
                    android:background="@drawable/button"
                    android:text="-"
                    android:textColor="@color/black" />

            </LinearLayout>

        </LinearLayout>

    </LinearLayout>


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_centerHorizontal="true"
        android:id="@id/linearlayout2btn"
        android:layout_marginTop="30dp"
        android:layout_below="@id/linearlayoutyourbalance">

        <Button
            android:id="@+id/btnUpdateBudgetHome"
            android:layout_width="130dp"
            android:layout_height="105dp"
            android:layout_marginRight="30dp"
            android:backgroundTint="#474747"
            android:drawableTint="#FCF8ED"
            android:drawableLeft="@drawable/ic_baseline_attach_money_24"
            android:text="@string/update_budget_amount"
            android:textColor="#fff"
            android:textSize="10sp" />

        <Button
            android:id="@+id/btnSeeStatistics"
            android:layout_width="130dp"
            android:layout_height="match_parent"
            android:backgroundTint="#474747"
            android:drawableTint="#FCF8ED"
            android:drawableLeft="@drawable/ic_baseline_bar_chart_24"
            android:text="Statistics"
            android:textColor="#fff"
            android:textSize="10sp" />

    </LinearLayout>


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:id="@+id/linearlayout4btn"
        android:layout_below="@id/linearlayout2btn">


        <Button
            android:id="@+id/btnViewCurrency"
            android:layout_width="130dp"
            android:layout_height="105dp"
            android:layout_marginRight="30dp"
            android:backgroundTint="#474747"
            android:drawableTint="#FCF8ED"
            android:drawableLeft="@drawable/ic_baseline_calculate_24"
            android:text="ONLINE CURRENCY"
            android:textColor="#fff"
            android:textSize="10sp" />

        <Button
            android:id="@+id/btnSeeATMS"
            android:layout_width="130dp"
            android:layout_height="match_parent"
            android:backgroundTint="#474747"
            android:drawableTint="#FCF8ED"
            android:drawableLeft="@drawable/ic_baseline_atm_24"
            android:text="@string/nearby_atms"
            android:textColor="#fff"
            android:textSize="10sp" />

    </LinearLayout>


    <LinearLayout
        android:id="@+id/menu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/black"
        android:backgroundTint="@color/black"
        android:textAlignment="center"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btnHomePageMain"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="0.95"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_attach_money_24"
            android:text="@string/home"
            android:textColor="#474747"
            android:textSize="10dp" />

        <Button
            android:id="@+id/btnTransactionMain"
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:layout_weight="1.1"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_playlist_add_check_24"
            android:text="@string/transactions"
            android:textColor="#474747"
            android:textSize="10dp" />

        <Button
            android:id="@+id/btnVaultsMain"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1.05"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_save_24"
            android:text="@string/vaults"
            android:textColor="#474747"
            android:textSize="10dp" />

        <Button
            android:id="@+id/btnSettingsMain"
            android:layout_width="15dp"
            android:layout_height="match_parent"
            android:layout_weight="1.1"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_vpn_key_24"
            android:text="@string/settings"
            android:textColor="#474747"
            android:textSize="10dp" />

    </LinearLayout>



</RelativeLayout>

我在 Google Maps 活动中使用的菜单代码 - 您可以看到菜单具有与主页中相同的属性和所有内容,但看起来仍然不同click to see how the menu looks like in the Google Maps activity

Google 地图活动的代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="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=".Activities.GoogleMapsActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:id="@+id/firstRelativeMap"
        android:background="@color/buttons">

        <EditText
            android:id="@+id/locationSearch"
            android:layout_width="314dp"
            android:layout_height="60dp"
            android:layout_alignParentStart="true"
            android:textColorHint="@color/text"
            android:layout_marginLeft="5dp"
            android:layout_alignParentTop="true"
            android:ems="10"
            android:onClick="onClick"
            android:backgroundTint="@color/buttons"
            android:hint="Write any location name">

        </EditText>

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_marginTop="7dp"
            android:id="@+id/locationSearchClick"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:onClick="onClick"
            android:src="@mipmap/search" />

    </RelativeLayout>


    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_marginTop="60dp"
        android:layout_above="@id/menu"
        android:layout_height="match_parent" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/menu"
        android:layout_below="@id/firstRelativeMap"
        android:id="@+id/secondRelativeMap">

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/ATMsNearby"
            android:layout_alignParentStart="true"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="50dp"
            android:onClick="onClick"
            android:src="@mipmap/atm" />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/BANKSNearby"
            android:layout_alignParentBottom="true"
            android:layout_toEndOf="@+id/ATMsNearby"
            android:onClick="onClick"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="50dp"
            android:src="@mipmap/bankhousepng" />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/EXCHANGENearby"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="50dp"
            android:layout_alignParentBottom="true"
            android:onClick="onClick"
            android:layout_toEndOf="@+id/BANKSNearby"
            android:src="@mipmap/exchange" />

    </RelativeLayout>


    <LinearLayout
        android:id="@+id/menu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/black"
        android:backgroundTint="@color/black"
        android:textAlignment="center"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btnHomePageTransactionVG"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="0.95"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_attach_money_24"
            android:text="@string/home"
            android:textColor="@color/text"
            android:textSize="10dp" />

        <Button
            android:id="@+id/btnTransactionTransactionVG"
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:layout_weight="1.1"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_playlist_add_check_24"
            android:text="@string/transactions"
            android:textColor="@color/text"
            android:textSize="10dp" />

        <Button
            android:id="@+id/btnVaultsTransactionVG"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1.05"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_save_24"
            android:text="@string/vaults"
            android:textColor="@color/text"
            android:textSize="10dp" />

        <Button
            android:id="@+id/btnSettingsTransactionVG"
            android:layout_width="15dp"
            android:layout_height="match_parent"
            android:layout_weight="1.1"
            android:backgroundTint="#FCF8ED"
            android:drawabletop="@drawable/ic_baseline_vpn_key_24"
            android:text="@string/settings"
            android:textColor="@color/text"
            android:textSize="10dp" />

    </LinearLayout>

</RelativeLayout>

有人能弄清楚为什么它在 Google 地图页面上看起来不同吗?我希望它看起来与主页完全一样。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...