Android--顶部导航栏

图片就自己找吧…

主页面布局

<!--    顶部导航栏-->
    <include layout="@layout/titlebar"/>

titlebar代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#000000"
    android:gravity="center_vertical">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/person2"
        android:layout_weight="1" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:hint="全网搜索"
        android:drawableLeft="@drawable/max2"
        android:background="@drawable/search_bg"
        app:iconifiedByDefault="false"/>
<!--    取出下面横线-->

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/email"/>
    
</LinearLayout>

嗯…选择与未选择的样式?

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false" android:drawable="@drawable/normal_bg"/>
    <item android:state_pressed="true" android:drawable="@drawable/normal_bg"/>

</selector>

形状:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<!--    下面这行数值越大,角位越弯曲-->
    <corners android:radius="200dp"/>
    <padding android:bottom="5dp" android:top="5dp" android:left="8dp" android:right="8dp"/>

    <solid android:color="#FFFFFF"/>
</shape>
原创文章 158 获赞 2 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43616001/article/details/104773994