线性布局在设计中可见,但在运行时不可见?

时间:2016-08-06 10:28:46

标签: android android-layout android-studio android-fragments

Xml代码......

 <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/orange"
            android:id="@+id/toolbar"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:title="Online Music and Vidio Player" />

        <android.support.v4.widget.DrawerLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:id="@+id/drawerLayout"
            >



            <FrameLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/containerView">

    //<<------------------------------------------->>>>
                <LinearLayout
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:tools="http://schemas.android.com/tools"
                    android:id="@+id/as"
                    android:layout_width="match_parent"
                    android:layout_height="73dp"
                    android:orientation="horizontal"
                    android:gravity="center_vertical"
                    android:background="@color/black"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:weightSum="1"
                    android:visibility="visible"
                    android:layout_gravity="bottom">
                    <!-- Previous Button -->
                    <ImageButton
                        android:id="@+id/btnPrevious"
                        android:src="@drawable/btn_previous"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@null"/>
                    <!-- Backward Button -->
                    <!-- Play Button -->
                    <ImageButton
                        android:id="@+id/btnPlay"
                        android:src="@drawable/btn_play"
                        android:layout_width="155dp"
                        android:layout_height="wrap_content"
                        android:background="@null"
                        android:layout_weight="1.03" />
                    <!-- Forward Button -->
                    <!-- Next Button -->
                    <ImageButton
                        android:id="@+id/btnNext"
                        android:src="@drawable/btn_next"
                        android:layout_width="102dp"
                        android:layout_height="104dp"
                        android:background="@null" />
                </LinearLayout>
//<<---------------------------------------------------->>
            </FrameLayout>






            <android.support.design.widget.NavigationView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:id="@+id/shitstuff"
                app:itemTextColor="@color/black"
                app:menu="@menu/drawermenu"
                android:layout_marginTop="-24dp"
                />



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

    </LinearLayout>
  

**在我的程序中,行内的代码不可见。这是一个

     
    

片段活动。框架布局内部的线性布局仅在UI设计中可见,同时运行不可用**

  

1 个答案:

答案 0 :(得分:1)

只需将您的FrameLayout更改为LinearLayout

 <LinearLayout
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:id="@+id/containerView">
     ...