我尝试使用android:listSelector,但只有当我点击listview单元格时,它才有效,如何更改所选单元格的高亮颜色,以便单元格将保持用该颜色突出显示?非常感谢.
在其left_drawer片段上有登录屏幕的导航抽屉应用程序(请参阅链接: 如何在android导航抽屉下显示活动(登录屏幕)),我想使用按钮从主屏幕打开此登录屏幕,也不想要导航抽屉上的操作栏.任何人都可以帮我这个吗?
提前致谢!!
我正在使用 v7 支持库。
当我尝试添加以下行 Window.FEATURE_ACTION_BAR_OVERLAY 时,它没有反映在 android 2.3 版上
android android-actionbar android-support-library navigation-drawer
我想在我的应用程序中添加导航抽屉.这是代码:
<DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.abcxyz.properprojectdb.MyDrawerActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
<ListView
android:layout_width="240dp"
android:layout_height="match_parent"
android:id="@+id/listView"
android:entries="@array/planets"></ListView>
</DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我无法为ListView添加属性android:layout_gravity.我不知道它为什么不能使用(intellisense工作得很好,但它不会显示layout_gravity)
我运行时我的应用程序崩溃,但如果我用LinearLayout替换DrawerLayout,应用程序不会崩溃.我猜这是因为我没有为ListView添加属性android:layout_gravity.
这是一个快照,显示layout_gravity也没有出现在intellisense中
android listview android-appcompat layout-gravity navigation-drawer
我试图按照样式设置导航抽屉 官方材料设计指南来设计。此处定义了所有内容,尽管第一行(配置文件部分)的背景图像大小。我所拥有的是:

但是如您所见,图像看起来像张拉了。我将其设置如下:
<?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="wrap_content"
android:background="@drawable/mat2" >
<com.blackB.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:background="@drawable/icon_default"
android:contentDescription="@string/imageviewContactus"
android:scaleType="centerCrop"
app:riv_border_color="#BDBDBD"
app:riv_border_width="0dip"
app:riv_corner_radius="38dip"
app:riv_mutate_background="true"
app:riv_oval="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="72dp"
android:gravity="left|center">
<TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"
android:layout_below="@+id/title"
android:text="Profile completion"
android:textColor="#FFFFFF"
android:textSize="14sp" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mr.Right"
android:textColor="#FFFFFF"
android:textSize="14sp" />
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用Imageview作为背景,但仍然可以拉伸。截至目前,我的图片规格为800x600px,与 google在iosched中使用图像并保存在drawable-nodpi内,就像Google所做的那样。
我在这里想念什么吗?请提出建议。谢谢 :)
我得到以下例外 -
Caused by: java.lang.IllegalStateException: RecyclerView has no LayoutManager
at android.support.v7.widget.RecyclerView.generateLayoutParams(RecyclerView.java:2820)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:757)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.peoplecloud.app.guggu.NavigationDrawerFragment.onCreateView(NavigationDrawerFragment.java:75)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:866)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1040)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1142)
at android.app.Activity.onCreateView(Activity.java:4803)
Run Code Online (Sandbox Code Playgroud)
我添加了以下代码,但是我仍然得到这个例外 -
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mDrawerList.setLayoutManager(layoutManager);
Run Code Online (Sandbox Code Playgroud)
如果我删除了回收站视图中的内容,那么没有例外.
如何更改<item>Navigation Drawer 元素内元素的大小?
无论图标似乎总是像这样自动调整为 24dp:
我需要将图标的大小增加到 34 dps,但<item>元素似乎没有任何属性来更改 XML 中的此设置:
谢谢。
当前状态:NavigationDrawer带有NavigationHeader和NavigationMenu项目.这些项目的数量很大,因此需要滚动才能访问底部的项目.
要求:当向下滚动到底部时,NavigationHeader应保持固定
这是我的activity_main布局文件
<android.support.v4.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">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="#00000000"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"
/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的navigation_header_main布局文件
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
android:background="#3d3b3b"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<android.support.v7.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:src="@drawable/categories"
android:padding="1dp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
PS我是android dev的新手.如果需要,请询问更多资源
错误信息:
android.view.InflateException:二进制XML文件行#16:二进制XML文件行#16:在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)错误膨胀类android.support.design.widget.NavigationView
xml文件:
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.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" />
Run Code Online (Sandbox Code Playgroud)
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "edu.zhanglrose_hulman.bigbelly"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:9.2.0'
}
Run Code Online (Sandbox Code Playgroud)
styles.xml
<!-- Base application theme. -->
<style name="AppTheme" …Run Code Online (Sandbox Code Playgroud) 大家.有可能Navigation View透明吗?我有自定义布局,并尝试为此布局设置50%透明背景,Navigation View或Drawer Layout.
android:background="#80000000"
Run Code Online (Sandbox Code Playgroud)
但它没有给出预期的结果.
有人试过这样吗?我很感激帮助.