搜索我试着研究这个了很多天。我真的不知道如何开始做一个非常类似于下面的风格。我知道它包含一个按钮和一个edittext。但是,我不知道如何开始。有人有类似风格的酒吧的示例代码? 如何做一个酒吧,一个类似的风格在android系统
2
A
回答
4
Android的搜索栏是本机和自定义元素的混合。
框架/碱/核心/ RES/RES /布局:
通过搜索栏使用的布局可以在机器人的源代码在这个路径(2.1版本,我可以我的硬盘驱动器上)中找到/search_bar.xml
可以发现以下布局的细节:
<view
xmlns:android="http://schemas.android.com/apk/res/android"
class="android.app.SearchDialog$SearchBar"
android:id="@+id/search_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:descendantFocusability="afterDescendants">
<!-- Outer layout defines the entire search bar at the top of the screen -->
<LinearLayout
android:id="@+id/search_plate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="12dip"
android:paddingRight="12dip"
android:paddingTop="7dip"
android:paddingBottom="16dip"
android:background="@drawable/search_plate_global" >
<!-- This is actually used for the badge icon *or* the badge label (or neither) -->
<TextView
android:id="@+id/search_badge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dip"
android:drawablePadding="0dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimaryInverse" />
<!-- Inner layout contains the app icon, button(s) and EditText -->
<LinearLayout
android:id="@+id/search_edit_frame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/search_app_icon"
android:layout_height="36dip"
android:layout_width="36dip"
android:layout_marginRight="7dip"
android:layout_gravity="center_vertical"
/>
<view class="android.app.SearchDialog$SearchAutoComplete"
android:id="@+id/search_src_text"
android:background="@drawable/textfield_search"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1.0"
android:paddingLeft="8dip"
android:paddingRight="6dip"
android:drawablePadding="2dip"
android:singleLine="true"
android:ellipsize="end"
android:inputType="text|textAutoComplete"
android:dropDownWidth="fill_parent"
android:dropDownHeight="fill_parent"
android:dropDownAnchor="@id/search_plate"
android:dropDownVerticalOffset="-9dip"
android:popupBackground="@android:drawable/search_dropdown_background"
/>
<!-- This button can switch between text and icon "modes" -->
<Button
android:id="@+id/search_go_btn"
android:background="@drawable/btn_search_dialog"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<ImageButton
android:id="@+id/search_voice_btn"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="8dip"
android:background="@drawable/btn_search_dialog_voice"
android:src="@android:drawable/ic_btn_speak_now"
/>
</LinearLayout>
</LinearLayout>
</view>
所有可绘制和样式也都在源代码。
为了让同样的事情,你必须将不同的元素在自己的项目复制。
您可能还来看看不同类别:
- SearchDialog.SearchBar
- SearchDialog.SearchAutoComplete
1
我从你的问题假设你想放的EditText和Button与Google搜索一样,并不完全是谷歌搜索实施。在android Activity的主LinearLayout中使用以下片段。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
如果你不是指我的感受,请告诉我。
Regards
相关问题
- 1. 一个厚的fci酒吧风格
- 2. 风格的Android ActionMode酒吧
- 3. Telerik RadCartesianChart酒吧系列风格
- 4. 如何设置酒吧风格的JFreeChart
- 5. 酒吧和ggplot2中的一个阴谋堆积的酒吧
- 6. 如何做一个@GET在RXJava在android系统
- 7. 如何创建一个Facebook风格的“喜欢”系统?
- 8. 做一个获取请求通过一个酒吧作为参数在url
- 9. Android的隐藏系统酒吧的Android 3.1
- 10. 如何正确使用类似系统的Twitter风格按钮
- 11. 风格化A <Select>酒吧
- 12. 重定向子域酒吧一个
- 13. 使一个酒吧滑到iPhone屏幕
- 14. 如何在UItableview中冻结一个酒吧
- 15. 如何在导航栏上放置一个酒吧按钮
- 16. 如何构建一个android系统
- 17. 如何让一个固定在视口底部的酒吧成为页脚底部的酒吧
- 18. Highcharts如何将一个额外的价值添加到酒吧
- 19. 如何访问一个JSON对象的值时,像“富$酒吧”
- 20. 做一个自己的系统栏
- 21. Android导航系统/酒吧方形按钮
- 22. 整个宽度的酒吧
- 23. 用OpenGL和GLUT创建一个FPS风格的运动系统
- 24. ZedGraph - 如何强制第一个和最后一个酒吧有X轴标签?
- 25. SearchView in Android酒吧
- 26. Android AChartEngine - Bar酒吧
- 27. Android - 星级酒吧
- 28. ORM /休眠模式:类Foo有很多酒吧,其中一个酒吧是默认的
- 29. 如何做一个“递归”手风琴
- 30. 使用Signalr有一个类似facebook的通知系统
OT:您截取了截屏工具。大声笑! :) – Mangusto
大声笑>可能是我习惯使用油漆做屏幕截图大声笑 – ericlee