這是布局:
創(chuàng)新互聯(lián)建站主營霍州網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,APP應(yīng)用開發(fā),霍州h5重慶小程序開發(fā)搭建,霍州網(wǎng)站營銷推廣歡迎霍州等地區(qū)企業(yè)咨詢
** android:clipChildren="false"**的意思是孩子的寬高不必受父親的約束,即可大過父布局,父親以及父親的父親都必須申明才可以,中間Imageview的android:layout_gravity="bottom"表示當(dāng)高度超過父布局時,底部對齊,于是就達(dá)到上圖的效果。
可以使用radiogroup做底部導(dǎo)航
radiogroup的屬性自定義,并設(shè)置android:button="@null"
?xml version="1.0" encoding="utf-8"?
LinearLayout xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="60dip"
android:background="@drawable/bottom_bg"
android:orientation="horizontal"
RadioGroup
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
RadioButton
style="@style/navigation_bottom_radio"
android:drawableTop="@drawable/bottom_home_d"
android:text="@string/home_tv" /
RadioButton
style="@style/navigation_bottom_radio"
android:drawableTop="@drawable/bottom_looks_d"
android:text="@string/style_tv" /
RadioButton
style="@style/navigation_bottom_radio"
android:drawableTop="@drawable/bottom_cam"
android:gravity="center"
android:text="拍照"
/
RadioButton
style="@style/navigation_bottom_radio"
android:drawableTop="@drawable/bottom_shopping_d"
android:text="@string/shopping_tv" /
RadioButton
style="@style/navigation_bottom_radio"
android:drawableTop="@drawable/bottom_show_d"
android:text="@string/show_tv" /
/RadioGroup
/LinearLayout
resources
style name="navigation_bottom_radio"
!-- 內(nèi)部組件的排列 --
item name="android:gravity"center_horizontal/item
!-- 背景樣式 --
item name="android:background"@drawable/style_navigation_radio/item
!-- 寬度 --
item name="android:layout_width"fill_parent/item
!-- 高度 --
item name="android:layout_height"wrap_content/item
!-- 設(shè)置RadioButton的原來圖片為空 --
item name="android:button"@null/item
!-- 與其他組件寬度占相同比重 --
item name="android:layout_weight"1.0/item
!-- 底部的空隙 --
item name="android:paddingBottom"2.0dip/item
!-- 頂部的空隙 --
item name="android:paddingTop"2.0dip/item
!-- 文字的大小 --
item name="android:textSize"11dip/item
!-- 文字的顏色 --
item name="android:textColor"@color/white/item
/style
/resources
參考:
咳咳,答應(yīng)過年增加新功能的,沒想到拖到現(xiàn)在,延遲了一個來月,尷尬,尷尬
那個,我們先忽略這尷尬的事情吧,進(jìn)入正題才是最重要滴
老規(guī)矩,先上效果圖:
跟原來的圖有個很明顯的區(qū)別,你們也一定都發(fā)現(xiàn)了,對不對。那么顯眼的小紅點,一定都看到了吧。
當(dāng)然除了這個,還增加了一項功能,雖然不是很明顯,但相信也有小伙伴發(fā)現(xiàn)了吧,截圖的這倆手機(jī)屏幕明顯大小不同,但是底部導(dǎo)航欄的大小還是相差不大滴。
是的,你們沒有看多,這次不僅增加了小紅點功能,還增加了底部導(dǎo)航欄的適配,你沒有聽錯,以后底部導(dǎo)航欄也不用那些dp、sp了,都按照UI妹子們標(biāo)注的px來就可以了,再也不用為了底部導(dǎo)航欄去跟UI妹子解釋啥叫dp了。
好了,效果圖展示完了,現(xiàn)在該進(jìn)入枯燥的使用介紹了。
由于這次改動有點大,所以,先介紹下上個穩(wěn)定版本的用法,到底是用最新的,還是用原來的,就看各位小伙伴的意愿了
上個穩(wěn)定版本是1.1.3的,引用方式如下
compile 'com.hjm:BottomTabBar:1.1.3'
具體用法如下(備注都加好了,我也就不多廢話了):
最新版本是1.2.2的,引用方式如下
compile 'com.hjm:BottomTabBar:1.2.2'
其實1.2.0與1.1.3區(qū)別并不大,只有4點改動:
現(xiàn)在默認(rèn)的,分割線高度都是設(shè)置的1個像素。這里以后也固定都用這個默認(rèn)的高度了,不再對外提供修改的方法。
這就是新增加的適配了,多的也不說了,你們都懂的
標(biāo)準(zhǔn)尺寸,就是UI妹子給你提供的效果圖的屏幕尺寸,只要在init()方法里添加上標(biāo)準(zhǔn)尺寸,你就可以放肆的使用px了
這個方法就是控制小紅點顯示的方法了,index就是需要顯示或者隱藏小紅點的TabItem,isShow是一個boolean類型的參數(shù),他是控制小紅點是否顯示的,如果為true,就會顯示小紅點;如果為false,就會隱藏小紅點
1.2.2版本新增了兩個方法
介紹到這里,超簡單的底部導(dǎo)航欄,第二階段就可以告一段落了。以后還會持續(xù)優(yōu)化,完善的。
第三階段我打算封裝一下有中間凸起的底部導(dǎo)航欄,這個功能我本地已經(jīng)做了,但是封裝進(jìn)去的時候,封裝的不理想,這次就沒有上線,留作下次了。
最后,再上個 GitHub 地址
很多android應(yīng)用底部都有一個底部導(dǎo)航欄,方便用戶在使用過程中隨意切換。目前常用的做法有三種:一種是使用自定義tabHost,一種是使用activityGroup,一種是結(jié)合FrameLayout實現(xiàn)。筆者再做了多款應(yīng)用后,為了節(jié)約開發(fā)周期,封裝了一個抽象類,只要三步便可完成底部欄的生成及不同頁面的調(diào)用。
public class ActivitycollectiondemoActivity extends ActivityCollection {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setBottomTabBackground(resId);// 設(shè)置底部導(dǎo)航背景圖
@Override
protected boolean isShowWindowFeature() {
return true;//設(shè)置是否顯示title;
@Override
protected ListIndicatorInfo setDrawableCollections() {
ListIndicatorInfo IndicatorInfos = new ArrayListIndicatorInfo();
IndicatorInfo indicatorInfo_1 = new IndicatorInfo(R.drawable.baby1,
R.drawable.baby1_s, R.string.baby1, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity01.class));
IndicatorInfo indicatorInfo_2 = new IndicatorInfo(R.drawable.baby2,
R.drawable.baby2_s, R.string.baby2, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity02.class));
IndicatorInfo indicatorInfo_3 = new IndicatorInfo(R.drawable.baby3,
R.drawable.baby3_s, R.string.baby3, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity03.class));
IndicatorInfo indicatorInfo_4 = new IndicatorInfo(R.drawable.baby4,
R.drawable.baby4_s, R.string.baby4, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity04.class));
IndicatorInfos.add(indicatorInfo_1);
IndicatorInfos.add(indicatorInfo_2);
IndicatorInfos.add(indicatorInfo_3);
IndicatorInfos.add(indicatorInfo_4);
return IndicatorInfos;
第一步:導(dǎo)入jar包;
第二步:讓你的homeactivity 繼承ActivityCollection類;
第三步:將你的圖片資源及跳轉(zhuǎn)intent放入list中,設(shè)置可選項;
雛形就形成啦!
當(dāng)前名稱:android底部欄,android 底部菜單
URL鏈接:http://muchs.cn/article42/phephc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、網(wǎng)站營銷、商城網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、微信公眾號、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)