我有一个搜索视图,我有一个查询提示属性.但是,只有在单击搜索视图后才会显示提示.有没有办法让它在被点击之前出现?
<SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView4"
android:layout_marginBottom="14dp"
android:layout_marginTop="30dp"
android:queryHint="Search" />
Run Code Online (Sandbox Code Playgroud)
我已经看到了另一个类似查询的SO问题,但它没有解决.这就是为什么我要再问一次.
每当我向我的活动添加ImageView时,我的应用程序中的导航抽屉都会滞后.没有图像,它运行顺畅.我猜测滞后是因为我们打开导航抽屉时活动不断刷新.图像分辨率约为1200x800.我尝试使用较低的res图像,但滞后仍然存在.我正在使用Android Studio 1.4中默认提供的导航抽屉活动
这是我的xml代码:
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".HomeScreen"
tools:showIn="@layout/app_bar_home_screen">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_margin="16dp"
android:text="Replace with home screen"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
andoird:scaleType="centerCrop"
android:layout_alignTop="@+id/textView"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:src="@drawable/dinner" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是抽屉布局xml代码:
<?xml version="1.0" encoding="utf-8"?>
<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_home_screen"
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_home_screen"
app:menu="@menu/home_screen_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
这是抽屉布局的java代码
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, …Run Code Online (Sandbox Code Playgroud) 我知道有两种方法可以创建Intent,它们是:
Intent intent = new Intent(this, Activity2.class);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
和
Intent intent = new Intent();
intent.setClassName(com.example.android.somepackagename, com.example.android.somepackagename.Activity2);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我知道两者基本上都做同样的事情,想知道是否有任何幕后差异,如果有特殊情况我们只需要使用一种类型.
谢谢