Android设计导航栏始终位于底部

时间:2015-10-24 20:29:31

标签: android navbar

有人可以帮我解决这个问题。我有登录和导航栏。当我包含导航栏登录登录时就消失了。我可以把这个导航栏放在所有活动的底部吗?这是登录代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#ffffff">

    <!--  Header  Starts-->
    <LinearLayout android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="70dp"
        android:orientation="vertical"
        android:background="@color/bitcolor"
        android:paddingTop="5dip"
        android:paddingBottom="5dip">

    </LinearLayout>
    <!--  Header Ends -->

    <!-- Login Form -->
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dip"
        android:layout_below="@id/header">
        <!--  Email Label -->
        <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#372c24"
            android:textSize="25dp"
            android:textStyle="bold"
            android:text="Email"/>
        <EditText android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/login_email"
            android:layout_marginTop="5dip"
            android:layout_marginBottom="20dip"
            android:textColor="#372c24"
            android:singleLine="true"/>
        <!--  Password Label -->
        <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#372c24"
            android:textSize="25dp"
            android:textStyle="bold"
            android:text="Password"/>
        <EditText android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/login_password"
            android:layout_marginTop="5dip"
            android:singleLine="true"
            android:textColor="#372c24"
            android:password="true"/>
        <!-- Login button -->
        <Button android:id="@+id/btnLogin"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="Login"/>
    </LinearLayout>
    <include
        layout="@layout/navbar" />
    <!-- Login Form Ends -->
</RelativeLayout>

导航栏的代码:

<?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"
android:background="@android:color/white"
>
<RadioGroup
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:background="@drawable/navbar_background"
    >
    <RadioButton
        android:id="@+id/btnAll"
        style="@style/navbar_button"
        android:drawableTop="@drawable/navbar_allselector"
        android:text="All"
        />
    <RadioButton
        android:id="@+id/btnPicture"
        style="@style/navbar_button"
        android:drawableTop="@drawable/navbar_pictureselector"
        android:text="Pictures"
        android:layout_marginLeft="5dp"
        />
    <RadioButton
        android:id="@+id/btnVideo"
        style="@style/navbar_button"
        android:drawableTop="@drawable/navbar_videoselector"
        android:text="Videos"
        android:layout_marginLeft="5dp"
        />
    <RadioButton
        android:id="@+id/btnFile"
        style="@style/navbar_button"
        android:drawableTop="@drawable/navbar_fileselector"
        android:text="Files"
        android:layout_marginLeft="5dp"
        />
</RadioGroup>

1 个答案:

答案 0 :(得分:0)

尝试使用此代码。将RelativeLayout更改为LinearLayout,并使用layout_weight = 1作为登录页面

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="#ffffff">

    <!--  Header  Starts-->
    <LinearLayout android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="70dp"
        android:orientation="vertical"
        android:background="@color/bitcolor"
        android:paddingTop="5dip"
        android:paddingBottom="5dip">

    </LinearLayout>
    <!--  Header Ends -->

    <!-- Login Form -->
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:padding="10dip"
        >
        <!--  Email Label -->
        <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#372c24"
            android:textSize="25dp"
            android:textStyle="bold"
            android:text="Email"/>
        <EditText android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/login_email"
            android:layout_marginTop="5dip"
            android:layout_marginBottom="20dip"
            android:textColor="#372c24"
            android:singleLine="true"/>
        <!--  Password Label -->
        <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#372c24"
            android:textSize="25dp"
            android:textStyle="bold"
            android:text="Password"/>
        <EditText android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/login_password"
            android:layout_marginTop="5dip"
            android:singleLine="true"
            android:textColor="#372c24"
            android:password="true"/>
        <!-- Login button -->
        <Button android:id="@+id/btnLogin"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="Login"/>
    </LinearLayout>
    <include
        layout="@layout/navbar" />
    <!-- Login Form Ends -->
</LinearLayout>