日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android 中radiogroup滑动切换,巧妙实现缺角radiogroup控制多个fragment切换和滑动

發布時間:2023/12/10 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 中radiogroup滑动切换,巧妙实现缺角radiogroup控制多个fragment切换和滑动 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在android開發中,用一個radiogroup控制多個fragment切換是十分常見的需求。但是如果fragment是一個ListView,如何保證滑動的時候通過缺角可以看到下面的listview是一個難點。

直接上圖:

(1)完美效果

(2)較差效果

另外,不妨假設缺角的高度是5dp,整個radioGroup的高度是50dp.還要求,不能遮擋listVIew第一個元素。

下面是我的主布局xml代碼:

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#fff5f5f5"

android:orientation="vertical" >

android:id="@+id/fragment_container"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_alignParentBottom="true"

android:layout_marginTop="45dp"

android:background="#f5f5f5"

/>

android:id="@+id/head_layout"

android:layout_width="fill_parent"

android:layout_height="wrap_content" >

android:id="@+idtton_group"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="horizontal" >

android:id="@+id/new_tag_button"

android:layout_width="0dp"

android:layout_height="50dp"

android:layout_weight="1"

android:background="@drawable/tab_radio_selector"

android:button="@color/trans_parent"

android:checked="true"

android:gravity="center"

android:text="最新"

android:textColor="#858585"

android:textSize="@dimen/font_size_38px" >

android:layout_width="1px"

android:layout_height="fill_parent"

android:background="#d2d2d2" />

android:id="@+id/hot_tag_button"

android:layout_width="0dp"

android:layout_height="50dp"

android:layout_weight="1"

android:background="@drawable/tab_radio_selector"

android:button="@color/trans_parent"

android:gravity="center"

android:text="最熱"

android:textColor="#858585"

android:textSize="@dimen/font_size_38px" >

另外,還需要對每個fragment的listView做如下處理

listView.addHeaderView(view);

這個view的背景設置為和listView中item的rootView背景一致,寬為fill_parent,高為5dp即可。要知道,只有headview是可以跟隨item一起滑動的哦,這個才是這個方案實現的關鍵!

總結

以上是生活随笔為你收集整理的android 中radiogroup滑动切换,巧妙实现缺角radiogroup控制多个fragment切换和滑动的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。