【发布时间】:2016-12-08 11:03:09
【问题描述】:
我在 Android Studio 预览中的 SearchView 如下所示:
https://i.stack.imgur.com/Khyy5.png
但在我的物理设备中,它看起来像这样:
https://i.stack.imgur.com/PlrFX.jpg
我该如何解决这个问题?让它不要在右侧扩展。我的 xml 中只有此代码
<SearchView
android:layout_width="343dp"
android:layout_height="wrap_content"
android:background="#fafafa"
android:layout_marginTop="65dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
【问题讨论】:
-
尝试将
android:layout_width="343dp"更改为android:layout_width="match_parent" -
@Char 你已经给定了边距,所以删除 343dp 并将 match_parent 设置为宽度
标签: android android-studio searchview android-search