我正在将背景图像设置为我的自定义按钮.我为我的应用程序制作了截图,并提到当我使用"wrap_content"作为按钮的宽度和高度时,按钮被拉伸.当我在dp中修改大小时,它会显得很好(例如:在我的mdpi文件夹中,我有48x48px图标,所以我把48dp放在宽度和高度上).你能解释一下为什么吗?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/definition_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp"
android:layout_alignParentTop="true" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" >
<Button
android:id="@+id/addToFavorites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/favorites_button" />
<Button
android:id="@+id/fontup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/fontup_button" />
<Button
android:id="@+id/fontdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/fontdown_button" />
<Button
android:id="@+id/comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/comment_button" />
<Button
android:id="@+id/speak"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/speak_button" />
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/buttons">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<WebView
android:id="@+id/webView1"
android:layout_below="@id/image_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
上面的代码显示了我的XML文件.您可以查看此链接以查看我的问题的屏幕截图: …
我使用了官方的Android示例代码"SearchableDictionary"(链接:http://jayxie.com/mirrors/android-sdk/resources/samples/SearchableDictionary/index.html ),它为我们提供了一个搜索界面,您可以在其中搜索一句话,你有两个选择:
1-输入关键字并单击搜索图标(键盘),以显示所有匹配结果的列表视图.单击ListView中的单词以检索定义.
2-每当searchView关键字发生变化时,放置关键字并自动显示一个建议列表,这样您就可以点击建议来检索她的定义.
这是当您单击大列表视图中的项而不是建议列表中时调用的搜索函数的代码.
private void doSearch(String queryStr) {
// get a Cursor, prepare the ListAdapter and set it
final DataBaseHelper myDbHelper = new DataBaseHelper(this);
myDbHelper.openDataBase();
Cursor cursor = managedQuery(DictionaryProvider.CONTENT_URI, null, null,
new String[] {queryStr}, null);
//Cursor cursor = myDbHelper.fetchListItems(queryStr);
//cursorr.moveToFirst(); // moves the cursor to the first row in the result set, returns false if the result set is empty.
startManagingCursor(cursor); /* Managing cursors take care of closing the cursor when
the activity is destroyed, but …Run Code Online (Sandbox Code Playgroud) android android-contentprovider android-listview search-suggestion