在创建带有导航抽屉活动的新项目之后,进行构建和运行,该活动将不起作用。从活动抽屉中选择这些片段时,应该将其更改为许多片段。打开抽屉,选择选项,仅看到:这是家庭片段。
2小时搜索网页,答案不清楚。 DrawerLayout的Z顺序
我只是希望模板在您运行时便能真正起作用。
答案 0 :(得分:3)
因此,要使导航抽屉活动(新模板中的模板,您可以从中创建一个新项目)完全起作用,您必须通过移动
来编辑activity_main.xml。1. On Ubuntu 16.06, I tried exporting the ‘base’ and ‘ai’ environments to .yml files, deleted ~/anaconda, reinstalled Anaconda and tried to restore my ‘ai’ environment.
condo complained about hundred of conflicts.
-rwxr-xr-x 1 ubuntu ubuntu 499266771 Sep 11 16:57 Anaconda2-2019.07-Linux-x86_64.sh
$ conda env create -f ai_environment.yml
NVIDIA: no NVIDIA devices found
Warning: you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your conda dependencies. Conda may not use the correct pip to install your packages, and they may end up in the wrong place. Please add an explicit pip dependency. I'm adding one for you, but still nagging you.
Collecting package metadata (repodata.json): / NVIDIA: no NVIDIA devices found
done
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
Examining backports.shutil_get_terminal_size: 21%|▏| 65/316 [00:00<00:00, 4464.Examining pyserial: 21%|████▏ | 66/316 [00:00<00:00, 4488.21it/s]Examining jupyter_nbextensions_configurator: 66%|▋| 210/316 [00:00<00:00, 4888.Examining packaging: 67%|████████████ | 211/316 [00:00<00:00, 4900.24it/s]Examining sphinxcontrib-serializinghtml: 88%|▉| 277/316 [00:00<00:00, 4816.54itExamining astor: 88%|███████████████████▎ | 278/316 [00:00<00:00, 4820.70itfailed
UnsatisfiableError: The following specifications were found to be incompatible with each other:
Package pyzmq conflicts for:
jupyter_client==5.2.3=py36_0 -> pyzmq[version='>=13']
notebook==5.7.8=py36_0 -> pyzmq[version='>=17']
Package mkl conflicts for:
mkl_fft==1.0.10=py36_0 -> mkl
pytorch==0.4.0=py36hdf912b8_0 -> mkl[version='>=2018.0.2,<2019.0a0']
mkl_random==1.0.2=py36_0 -> mkl
Package ujson conflicts for:
spacy==2.0.12=py36h962f231_0 -> ujson[version='>=1.35']
Package jinja2 conflicts for:
notebook==5.7.8=py36_0 -> jinja2
nbconvert==5.5.0=py_0 -> jinja2
Package h5py conflicts for:
keras-base==2.2.4=py36_0 -> h5py
Package libsodium conflicts for:
pyzmq==17.0.0=py36h14c3975_0 -> libsodium
zeromq==4.2.5=h439df22_0 -> libsodium[version='>=1.0.16,<1.0.17.0a0']
Package keras-preprocessing conflicts for:
keras-base==2.2.4=py36_0 -> keras-preprocessing[version='>=1.0.5']
tensorflow==1.13.1=py36_0 -> keras-preprocessing[version='>=1.0.5']
Package murmurhash conflicts for:
spacy==2.0.12=py36h962f231_0 -> murmurhash[version='>=0.28,<0.29']
Package libgfortran-ng conflicts for:
hdf5==1.10.2=hba1933b_1 -> libgfortran-ng[version='>=7,<8.0a0']
libopenblas==0.3.3=h5a2b251_3 -> libgfortran-ng[version='>=7,<8.0a0']
blas==2.7=openblas -> libgfortran-ng[version='>=7,<8.0a0']
numpy-base==1.16.2=py36h2f8d375_0 -> libgfortran-ng[version='>=7,<8.0a0']
Package protobuf conflicts for:
chainer==4.2.0=py36_0 -> protobuf[version='>=3.0.0']
tensorflow==1.13.1=py36_0 -> protobuf[version='>=3.6.1']
tensorflow-tensorboard==1.5.1=py36hf484d3e_1 -> protobuf
tensorboard==1.13.1=py36_0 -> protobuf[version='>=3.4.0']
Package tk conflicts for:
python==3.6.7=h0371630_0 -> tk[version='>=8.6.8,<8.7.0a0']
Package blas conflicts for:
libcblas==3.8.0=7_openblas -> blas=[build=openblas]
scikit-learn==0.20.3=py36h22eb022_0 -> blas=[build=openblas]
libblas==3.8.0=7_openblas -> blas=[build=openblas]
liblapacke==3.8.0=7_openblas -> blas=[build=openblas]
numpy-base==1.16.2=py36h2f8d375_0 -> blas=[build=openblas]
nomkl==3.0=0 -> blas=[build=openblas]
liblapack==3.8.0=7_openblas -> blas=[build=openblas]
Package keras-applications conflicts for:
keras-base==2.2.4=py36_0 -> keras-applications[version='>=1.0.6']
tensorflow==1.13.1=py36_0 -> keras-applications[version='>=1.0.6']
Package ninja conflicts for:
pytorch==0.4.0=py36hdf912b8_0 -> ninja
Package requests conflicts for:
spacy==2.0.12=py36h962f231_0 -> requests[version='>=2.13.0,<3.0.0']
Package dbus conflicts for:
qt==5.9.7=h5867ecd_1 -> dbus[version='>=1.13.2,<2.0a0']
pyqt==5.9.2=py36h751905a_0 -> dbus[version='>=1.12.2,<2.0a0']
Package pandocfilters conflicts for:
nbconvert==5.5.0=py_0 -> pandocfilters[version='>=1.4.1']
Package liblapacke conflicts for:
libblas==3.8.0=7_openblas -> liblapacke==3.8.0=7_openblas
libcblas==3.8.0=7_openblas -> liblapacke==3.8.0=7_openblas
liblapack==3.8.0=7_openblas -> liblapacke==3.8.0=7_openblas
blas==2.7=openblas -> liblapacke==3.8.0=7_openblas
Package ptyprocess conflicts for:
pexpect==4.6.0=py36_0 -> ptyprocess[version='>=0.5']
terminado==0.8.1=py36_1 -> ptyprocess
Package nbformat conflicts for:
nbconvert==5.5.0=py_0 -> nbformat[version='>=4.4']
notebook==5.7.8=py36_0 -> nbformat
Package _libgcc_mutex conflicts for:
libgcc-ng==8.2.0=hdf63c60_1 -> _libgcc_mutex=[build=main]
Package cudnn conflicts for:
pytorch==0.4.0=py36hdf912b8_0 -> cudnn[version='>=7.1.2,<=8.0a0']
Package zeromq conflicts for:
pyzmq==17.0.0=py36h14c3975_0 -> zeromq[version='>=4.2.3,<4.3']
Package pygments conflicts for:
prompt_toolkit==2.0.9=py_0 -> pygments
ipython==7.5.0=py36h24bf2e0_0 -> pygments
nbconvert==5.5.0=py_0 -> pygments
Package plac conflicts for:
spacy==2.0.12=py36h962f231_0 -> plac[version='>=0.9.6,<1.0.0']
Package pango conflicts for:
graphviz==2.40.1=h21bd128_2 -> pango[version='>=1.42.1,<2.0a0']
Package python conflicts for:
tornado==5.0.2=py36_0 -> python[version='3.6.*|>=3.6,<3.7.0a0']
pycparser==2.18=py36hf9f622e_1 -> python[version='>=3.6,<3.7.0a0']
jupyter_core==4.4.0=py36h7c827e3_0 -> python[version='>=3.6,<3.7.0a0']
murmurhash==0.28.0=py36_0 -> python=3.6
python-dateutil==2.7.3=py36_0 -> python[version='>=3.6,<3.7.0a0']
filelock==3.0.4=py36_0 -> python[version='3.6.*|>=3.6,<3.7.0a0']
multicore-tsne==0.1_d4ff4aab=py36h3e44d54_0 -> python[version='>=3.6,<3.7.0a0']
pexpect==4.6.0=py36_0 -> python[version='>=3.6,<3.7.0a0']
idna==2.7=py36_0 -> python[version='>=3.6,<3.7.0a0']
tblib==1.3.2=py36h34cf8b6_0 -> python[version='>=3.6,<3.7.0a0']
astor==0.6.2=py36_0 -> python[version='>=3.6,<3.7.0a0']
jupyterlab==0.32.1=py36_0 -> python[version='>=3.6,<3.7.0a0']
scikit-learn==0.20.3=py36h22eb022_0 -> python[version='>=3.6,<3.7.0a0']
numpy-base==1.16.2=py36h2f8d375_0 -> python[version='>=3.6,<3.7.0a0']
jupyterlab_launcher==0.10.5=py36_0 -> python[version='3.6.*|>=3.6,<3.7.0a0']
kiwisolver==1.0.1=py36h764f252_0 -> python[version='>=3.6,<3.7.0a0']
ujson==1.35=py36_0 -> python=3.6
cycler==0.10.0=py36h93f1223_0 -> python[version='>=3.6,<3.7.0a0']
boto==2.48.0=py36h6e4cd66_1 -> python[version='>=3.6,<3.7.0a0']
ipykernel==5.1.1=py36h24bf2e0_0 -> python[version='>=3.6,<3.7.0a0']
six==1.12.0=py36_0 -> python[version='>=3.6,<3.7.0a0']
requests==2.22.0=py36_1 -> python[version='>=3.6,<3.7.0a0']
pyemd==0.5.1=py36ha8d69ae_0 -> python[version='>=3.6,<3.7.0a0']
tensorflow-probability==0.5.0=py_1 -> python
chainer==4.2.0=py36_0 -> python[version='>=3.6,<3.7.0a0']
docutils==0.14=py36hb0f60f5_0 -> python[version=
…
2. I tried exporting my ‘ai’ environment from my Mac and importing it on Ubuntu 16.06. I
failed because of missing packages. Are these packages that I built from source that conda can’t find?
(base) ubuntu@ip-10-0-1-71:~$ conda env create -f ai_mac_environment.yml
NVIDIA: no NVIDIA devices found
Collecting package metadata (repodata.json): | NVIDIA: no NVIDIA devices found
done
Solving environment: failed
ResolvePackageNotFound:
- pymongo==3.7.2=py36h0a44026_0
- pygpu==0.7.6=py36h917ab60_1000
- gensim==3.4.0=py36h1de35cc_0
- pytorch==1.1.0=py3.6_0
- ninja==1.9.0=h04f5b5a_0
- matplotlib==2.2.2=py36ha7267d0_0
- graphviz==2.38.0=hbeef861_8
- openssl==1.1.1=h1de35cc_0
- scikit-learn==0.20.3=py36hebd9d1a_0
- libgpuarray==0.7.6=h1de35cc_1003
- kiwisolver==1.1.0=py36h770b8ee_0
- tornado==6.0.2=py36h01d97ff_0
- python==3.6.7=haf84260_0
- libopenblas==0.3.3=hdc02c5d_3
- tensorboard==1.12.2=py36haf313ee_0
- msgpack-python==0.6.1=py36h04f5b5a_0
- grpcio==1.12.1=py36hd9629dc_0
- webencodings==0.5.1=py36_0
- tensorflow-base==1.12.0=mkl_py36h70e0e9a_0
- pandoc==2.2.1=hde52d81_0
- appnope==0.1.0=py36_0
- boto==2.48.0=py36hdbc59ac_1
- libprotobuf==3.6.1=hd9629dc_1000
- protobuf==3.6.1=py36h0a44026_1001
- xz==5.2.4=h1de35cc_4
- python-crfsuite==0.9.6=py36h04f5b5a_1000
- readline==7.0=hc1231fa_4
- thinc==6.10.1=py36h17d75cb_0
- libgfortran==3.0.1=h93005f0_2
- scipy==1.2.1=py36hbd7caa9_1
- cymem==1.31.2=py36hfc679d8_0
- numpy-base==1.16.2=py36ha711998_0
- openblas==0.3.5=h436c29b_1001
- numpy==1.16.2=py36hbb3c62a_1
- cryptography==2.3.1=py36ha12b0ac_2
- tensorflow==1.12.0=mkl_py36h2b2bbaf_0
3. I tried reverting conda to rev 0 after reinstalling Anaconda2-2019.07-Linux-x86_64.sh
4. I tried to install my previous environment with
$ conda env create -f ai_environment.yml
This got hundreds of conflicts
5. I tried to install my mac environment with:
$ conda env create -f ai_mac_environment_1.yml
this got ResolvePackageNotFound: with 38 missing packages.
6. I deleted the missing packages from ai_mac_environment_1.yml and tried again.
NVIDIA: no NVIDIA devices found
Collecting package metadata (repodata.json): \ NVIDIA: no NVIDIA devices found
done
Solving environment: failed
UnsatisfiableError: The following specifications were found to be incompatible with each other:
Package libpng conflicts for:
pillow==5.2.0=py36h2dc6135_1 -> freetype[version='>=2.8,<2.9.0a0'] -> libpng[version='1.6.*,>=1.6.23,<1.7,>=1.6.27,<1.7,>=1.6.32,<1.6.35,>=1.6.34,<1.7.0a0']
freetype==2.8.1=0 -> libpng[version='1.6.*,>=1.6.23,<1.7,>=1.6.27,<1.7,>=1.6.32,<1.6.35,>=1.6.34,<1.7.0a0']
bokeh==1.0.1=py36_1000 -> pillow[version='>=4.0'] -> freetype[version='2.7|2.7.*,>=2.8,<2.9.0a0,>=2.9.1,<3.0a0'] -> libpng[version='1.6.*,>=1.6.23,<1.7,>=1.6.27,<1.7,>=1.6.32,<1.6.35,>=1.6.34,<1.7.0a0']
libpng==1.6.34=ha92aebf_1
seaborn==0.9.0=py_0 -> matplotlib[version='>=1.4.3'] -> pyqt[version='4.*,5.*,5.6.*,5.9.*,>=5.9.2,<5.10.0a0'] -> qt[version='4.8.*,5.6.*,>=4.8.6,<5.0,>=5.6.2,<5.7.0a0'] -> gtk2 -> pango[version='1.40.*,>=1.40.14,<1.41.0a0,>=1.42.4,<1.43.0a0'] -> harfbuzz[version='0.9.*,>=1.7.6,<1.8.0a0,>=1.7.6,<2.0a0,>=1.9.0,<2.0a0,>=2.4.0,<3.0a0'] -> cairo[version='1.14.*,>=1.14.12,<1.15.0a0,>=1.14.12,<2.0a0,>=1.16.0,<1.17.0a0'] -> fontconfig[version='2.11.1,2.12.*,>=2.12.4,<3.0a0,>=2.13.1,<3.0a0'] -> freetype[version='2.5.*,2.6.*,2.8.1,>=2.8,<2.9.0a0,>=2.8.1,<2.9.0a0,>=2.9.1,<3.0a0'] -> libpng[version='1.6.*,>=1.6.23,<1.7,>=1.6.27,<1.7,>=1.6.32,<1.6.35,>=1.6.34,<1.7.0a0']
torchvision==0.2.1=py_2 -> pillow[version='>=4.1.1'] -> freetype[version='2.7|2.7.*,>=2.8,<2.9.0a0,>=2.9.1,<3.0a0'] -> libpng[version='1.6.*,>=1.6.23,<1.7,>=1.6.27,<1.7,>=1.6.32,<1.6.35,>=1.6.34,<1.7.0a0']
pydot==1.3.0=py36_1000 -> graphviz -> pango[version='>=1.41.0,<2.0a0,>=1.42.1,<2.0a0,>=1.42.4,<1.43.0a0'] -> harfbuzz[version='0.9.*,>=1.7.6,<1.8.0a0,>=1.7.6,<2.0a0,>=1.9.0,<2.0a0,>=2.4.0,<3.0a0'] -> cairo[version='1.14.*,>=1.14.12,<1.15.0a0,>=1.14.12,<2.0a0,>=1.16.0,<1.17.0a0'] -> fontconfig[version='2.11.1,2.12.*,>=2.12.4,<3.0a0,>=2.13.1,<3.0a0'] -> freetype[version='2.5.*,2.6.*,2.8.1,>=2.8,<2.9.0a0,>=2.8.1,<2.9.0a0,>=2.9.1,<3.0a0'] -> libpng[version='1.6.*,>=1.6.23,<1.7,>=1.6.27,<1.7,>=1.6.32,<1.6.35,>=1.6.34,<1.7.0a0']
上方
<include
layout="@layout/app_bar_main"
然后,该程序将运行,您可以从那里继续。
所以改变:
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
收件人
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.drawerlayout.widget.DrawerLayout>
我希望这可以帮助一个不像我那样花时间的人。 这里的教训是:仅仅因为开发人员提供了模板,并不意味着它可以正常工作。因此,不要自动认为程序不起作用是您的错。
答案 1 :(得分:0)
如果您查看模板本身(在{ANDROID_STUDIO_LOCATION}\plugins\android\lib\templates\activities\NavigationDrawerActivity\root\res-buildApi22\layout\navigation_view.xml.ftl
下,则可以看到正确的顺序:
<androidx.drawerlayout.widget.DrawerLayout>
<include layout="@layout/app_bar_main" />
<com.google.android.material.navigation.NavigationView />
</androidx.drawerlayout.widget.DrawerLayout>
但是,有一个known issue with Android Studio 3.5导致XML属性的重新排序。如果将include
和NavigationView
交换,您将得到您遇到的症状。对于其他问题,您需要将XML的代码样式重置为预定义样式“ Android”,以解决潜在问题。否则,您的XML文件将继续重新排序。