如何制作左上角和右下角的搜索栏?
下面的代码使它全部圆润,但我想成为类似的东西 此图片中显示here。 如果有人能帮助我,我会很开心^^
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@id/search_bar_container"
android:background="@*android:color/primary_material_dark"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:cardElevation="50.0dip">
<android.support.v7.widget.CardView
android:id="@id/search_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/search_bar_margin"
app:cardCornerRadius="24.0dip"
app:cardElevation="50.0dip"
app:cardBackgroundColor="@*android:color/primary_material_dark">
<Toolbar
android:id="@id/search_action_bar"
android:theme="?android:attr/actionBarTheme"
android:contentInsetStartWithNavigation="64dp"
android:navigationIcon="@drawable/ic_search_24dp"
android:navigationContentDescription="@string/search_menu"
android:background="@color/background_floating_material_dark"
android:layout_width="fill_parent"
android:layout_height="@dimen/search_bar_height"
android:titleTextAppearance="@style/TextAppearance.SearchBar"
android:title="@string/search_menu" />
</android.support.v7.widget.CardView>
</FrameLayout>
<FrameLayout
android:id="@id/main_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
答案 0 :(得分:0)
在drawable文件夹中创建background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:topLeftRadius="19dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="16dp"
/>
<solid
android:color="#002f00"
/>
<size
android:width="270dp"
android:height="60dp"
/>
<stroke
android:width="2dp"
android:color="#00fe00"
/>
</shape>
使用此drawable设置编辑文本的背景。更改半径值以获得所需的半径。
输出就像