对于我的音乐应用程序,我想添加一个底栏,作为当前播放显示。因为我想对所有片段使用一个,我只想在MainActivity中添加它。但我不确定如何在布局方式中做到这一点。你可以帮助我吗?
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:background="@color/sonatic_darker"
android:layout_height="match_parent">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/frame_container"
android:fitsSystemWindows="true"
android:clipToPadding="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--
<ListView
android:id="@+id/list_slidermenu"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:layout_width="270dp"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector"
android:background="@drawable/sidebar_background_xml"/> -->
<RelativeLayout
android:id="@+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sidebar_background_xml"
android:layout_gravity="start" >
<ListView
android:id="@+id/list_slidermenu"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:layout_width="270dp"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector"
android:background="@android:color/transparent"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true" >
<ImageView
android:id="@+id/profile_image"
android:layout_width="25dp"
android:clipToPadding="true"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:layout_marginLeft="17dp"
android:layout_marginRight="24dp"
android:src="@drawable/ic_sonatic"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="true"
android:fontFamily="sans-serif-light"
fontPath="SeraRegular.ttf"
android:layout_toRightOf="@id/profile_image"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/list_item_title_selected"
android:textColorHighlight="@color/list_item_title_selected"
android:gravity="center_vertical"
android:textSize="18sp"
android:text="@string/app_name"
android:paddingRight="10dp"/>
<TextView android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:clipToPadding="true"
android:background="@android:color/transparent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
fontPath="SeraRegular.ttf"
android:layout_marginRight="8dp"
android:textColor="#FFFFFF"/>
</RelativeLayout>
</RelativeLayout>
答案 0 :(得分:1)
嘿,根据您的需要,按照以下代码进行抽屉布局,
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayou
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayou
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--your bottom bar elements-->
</LinearLayou>
</LinearLayou>
<!--your drawer menu-->
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</android.support.v4.widget.DrawerLayout>