gpt4 book ai didi

android - 抽屉导航 Android 上的底部布局

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:47:01 24 4
gpt4 key购买 nike

尝试向包含两个列表的抽屉导航添加页脚。我这样做不对,我知道我想要在抽屉导航中的任何东西都应该封装在

<LinearLayout
android:id="@+id/left_drawer_layout"

我想添加一个不依赖于 ListView 滚动的底部布局。我尝试了不同版本的添加底部布局代码的位置,但没有任何反应。我需要一只额外的眼睛,拜托。谢谢。

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

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

<include
android:id="@+id/toolbar"
layout="@layout/toolbar”/>



<!-- Framelayout to display Fragments -->

<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />

</LinearLayout>


<!-- Listview to display slider menu -->

<LinearLayout
android:id="@+id/left_drawer_layout"
android:layout_width="@dimen/navigation_drawer_max_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical">


<FrameLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/list_background">

<Button
android:id="@+id/refreshBtn"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="@string/refresh"
android:visibility="gone" />

<EditText
android:id="@+id/searchMenuTxt"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/list_background_pressed"
android:drawableLeft="@drawable/search_web"
android:drawablePadding="@dimen/activity_horizontal_margin"
android:drawableStart="@drawable/search_web"
android:focusable="false"
android:focusableInTouchMode="true"
android:hint="@string/search"
android:paddingLeft="8dp"
android:singleLine="true"
android:textColorHint="@android:color/darker_gray"
android:textSize="@dimen/text_size_14"></EditText>

<Button
android:id="@+id/clearBtn"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="right|center"
android:background="@drawable/mob_clear"
android:paddingRight="8dp"
android:visibility="invisible" />

</FrameLayout>

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

<ListView
android:id="@+id/activeChatsList"
android:layout_width="@dimen/navigation_drawer_max_width"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="@color/list_background_pressed"
android:choiceMode="singleChoice"
android:divider="@drawable/list_divider"
android:dividerHeight="1dp"
android:fadeScrollbars="false"
android:fastScrollEnabled="false" />

<ListView
android:id="@+id/drawerListView"
android:layout_width="@dimen/navigation_drawer_max_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@drawable/list_selector"
android:choiceMode="singleChoice"
android:divider="@drawable/list_divider"
android:dividerHeight="1dp"
android:drawSelectorOnTop="true"
android:fastScrollEnabled="false"
android:minHeight="250dp" />
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentBottom="true">

<Button android:id="@+id/CancelButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=“Profile" />
>

</LinearLayout>
</LinearLayout>


</LinearLayout>

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

最佳答案

您可以从这段代码中了解基本思路。android 现在具有菜单抽屉的内置功能。您正在尝试做的是旧方法。操作栏 sherlock 已弃用。所以我建议您转到 AppCompat。使用 Appcompat,以下是具有菜单抽屉布局和页脚的代码。

drawer_fragment.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.focial"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >

<LinearLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:clickable="true"
android:background="@android:color/black"
android:orientation="vertical">

<!-- any addition stuff you want in yoour footer layout -->

</LinearLayout>

<ListView
android:id="@+id/drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/footer"
android:choiceMode="singleChoice"
android:dividerHeight="1dp" />
</RelativeLayout>

activity_home.xml(您要启用/显示抽屉的位置)

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >

<FrameLayout
android:id="@+id/realcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<fragment
android:id="@+id/navigation_drawer"
android:name="com.focial.fragment.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start" />

HomeActivity.java

private NavigationDrawerFragment mNavigationDrawerFragment;
private ArrayList<DrawerItem> drawerItems;
private DrawerLayout drawerLayout;

protected void initUIComponents() {
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
mNavigationDrawerFragment.setUp(R.id.navigation_drawer, drawerLayout, drawerItems);
}

@Override
public void onNavigationDrawerItemSelected(int itemlabelId) {
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.realcontent, CustomFragmentManager.newInstance(itemlabelId)).commit();
}

NavigationDrawerFragment.java

View rootView = (RelativeLayout) inflater.inflate(R.layout.layout_fragment_drawer, container, false);
ListView mDrawerListView = (ListView) rootView.findViewById(R.id.drawer_list);
LinearLayout footerView = (LinearLayout) rootView.findViewById(R.id.footer);

关于android - 抽屉导航 Android 上的底部布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31664860/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com