布局
-
activity_main`
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width=“match_parent”
android:layout_height=“0dp”
android:layout_weight=“1”>
</androidx.viewpager.widget.ViewPager><com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width=“match_parent”
android:layout_height=“wrap_content” />` -
activity_show`
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width=“match_parent”
android:layout_height=“match_parent”></androidx.recyclerview.widget.RecyclerView>` -
fragment_home`
<com.bawei.month_demo_02.view.MySearchView
android:id="@+id/mySearchView"
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
app:_hint=“请输入…”
app:_leftImage="@mipmap/ic_launcher"
app:_midSize=“8sp” /><com.bawei.month_demo_02.view.MyFlowView
android:id="@+id/myFlowView"
app:_tagSize=“15sp”
app:_tagSpace=“20dp”
android:layout_width=“match_parent”
android:layout_height=“match_parent”/>` -
fragment_my`
< Button
android:id="@+id/btnChangeColor"
android:text=“改变颜色”
android:layout_width=“match_parent”
android:layout_height=“wrap_content” />< Button
android:id="@+id/btnJs"
android:text=“js弹框”
android:layout_width=“match_parent”
android:layout_height=“wrap_content” />< WebView
android:id="@+id/webView"
android:layout_width=“match_parent”
android:layout_height=“match_parent”>` -
item_layout`
< ImageView
android:id="@+id/imag"
android:layout_gravity=“center”
android:layout_margin=“10dp”
android:layout_width=“100dp”
android:layout_height=“100dp” />
< TextView
android:id="@+id/text_name"
android:layout_width=“match_parent”
android:layout_height=“wrap_content” />
< TextView
android:id="@+id/text_price"
android:layout_width=“match_parent”
android:layout_height=“wrap_content” />` -
layout_my_search_view`
< ImageView
android:id="@+id/ivLeft"
android:layout_marginLeft=“130dp”
android:layout_marginTop=“5dp”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content” />< EditText
android:id="@+id/etContent"
android:layout_width=“200dp”
android:layout_marginTop=“10dp”
android:layout_height=“wrap_content” />< TextView
android:id="@+id/tvRight"
android:text=“搜索”
android:textSize=“16sp”
android:layout_marginTop=“10dp”
android:gravity=“center_vertical”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content” />`
另附:
-
attr`
< resources>
< declare-styleable name=“MySearchView”>
< attr name="_leftImage" format=“reference”>
< attr name="_midColor" format=“color”>
< attr name="_midSize" format=“dimension”>
< attr name="_hint" format=“string”>
< attr name="_hintColor" format=“color”>
< attr name="_rightColor" format=“color”>
< attr name="_rightBgColor" format=“color”>
< /declare-styleable>< declare-styleable name=“MyFlowView”>
< attr name="_tagColor" format=“color”>
< attr name="_tagSize" format=“dimension”>
< attr name="_tagSpace" format=“dimension”>
< /declare-styleable>
< /resources>`
依赖
implementation ‘com.youth.banner:banner:1.4.9’
implementation ‘com.github.bumptech.glide:glide:4.9.0’
annotationProcessor ‘com.github.bumptech.glide:compiler:4.9.0’
implementation ‘com.google.code.gson:gson:2.6.2’
implementation ‘com.mcxiaoke.volley:library:1.0.19’
implementation ‘com.android.support:design:28.0.0’
implementation ‘com.android.support:recyclerview-v7:28.0.0’
implementation ‘com.jcodecraeer:xrecyclerview:1.3.2’
implementation ‘com.android.support:design:28.0.0’
别忘了网络权限和app注册
________________________________________(完)