『壹』 android開發中有沒有使底部虛擬導航條隱藏的規范
沒有這樣的規范。
這個的原因應該有好多,具體可能有下面三個:
國內的產品經理很多不懂技術,並且平時使用的應用一般都專注在某個領域。
程序員對新的技術或者說新的版本沒有及時學習研究。
用戶對設備更新不及時。、
這里先不提產品經理。
很多程序員是沒有時間也沒有意識學習最近的技術的,對外說,國內這個氛圍不濃;對內說,自己的學習動力不足,自律性和執行力不夠。所以大多數是看到別人開發瞭然後自己才跟上更改。
具體來說,如果想及時應用谷歌的最新SDK,通用流程應該是這樣的:(這里排除對某些功能一直耿耿於懷,每次一有更新就馬上直奔主題去check是否更新的情況)
谷歌推出最新的SDK -> 立即研究學習,這可能會用掉幾天,一個星期,甚至更多的時間 ->修改自己的應用。
『貳』 android開發時如何去掉底部的導航欄
在一個普通類中(非繼承Activity等),點擊截界面上某一按鈕隱藏底部導航欄(Back、Home、多任務切換),再次點擊讓其出現;
實現:隱藏view.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| Utils.SYSTEM_UI_FLAG_IMMERSIVE);
顯示view.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
而且加了界面touch監聽,在隱藏模式下,單擊屏幕不讓導航欄出現;
『叄』 android 怎麼實現左側導航欄
Android左側推出導航菜單可以讓Activity繼承PopupWindow類來實現的彈出窗體,布局可以根據自己定義設計。彈出效果主要使用了translate和alpha樣式實現。具體的做法是下列代碼:
第一步:設計彈出窗口xml:
Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/pop_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:background="@drawable/btn_style_alert_dialog_background"
>
<Button
android:id="@+id/btn_take_photo"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="20dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="拍照"
android:background="@drawable/btn_style_alert_dialog_button"
android:textStyle="bold"
/>
<Button
android:id="@+id/btn_pick_photo"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="5dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="從相冊選擇"
android:background="@drawable/btn_style_alert_dialog_button"
android:textStyle="bold"
/>
<Button
android:id="@+id/btn_cancel"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="15dip"
android:layout_marginBottom="15dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="取消"
android:background="@drawable/btn_style_alert_dialog_cancel"
android:textColor="#ffffff"
android:textStyle="bold"
/>
</LinearLayout>
</RelativeLayout>
第二步:創建SelectPicPopupWindow類繼承PopupWindow:
java代碼
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;
public class SelectPicPopupWindow extends PopupWindow {
private Button btn_take_photo, btn_pick_photo, btn_cancel;
private View mMenuView;
public SelectPicPopupWindow(Activity context,OnClickListener itemsOnClick) {
super(context);
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mMenuView = inflater.inflate(R.layout.alert_dialog, null);
btn_take_photo = (Button) mMenuView.findViewById(R.id.btn_take_photo);
btn_pick_photo = (Button) mMenuView.findViewById(R.id.btn_pick_photo);
btn_cancel = (Button) mMenuView.findViewById(R.id.btn_cancel);
//取消按鈕
btn_cancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//銷毀彈出框
dismiss();
}
});
//設置按鈕監聽
btn_pick_photo.setOnClickListener(itemsOnClick);
btn_take_photo.setOnClickListener(itemsOnClick);
//設置SelectPicPopupWindow的View
this.setContentView(mMenuView);
//設置SelectPicPopupWindow彈出窗體的寬
this.setWidth(LayoutParams.FILL_PARENT);
//設置SelectPicPopupWindow彈出窗體的高
this.setHeight(LayoutParams.WRAP_CONTENT);
//設置SelectPicPopupWindow彈出窗體可點擊
this.setFocusable(true);
//設置SelectPicPopupWindow彈出窗體動畫效果
this.setAnimationStyle(R.style.AnimBottom);
//實例化一個ColorDrawable顏色為半透明
ColorDrawable dw = new ColorDrawable(0xb0000000);
//設置SelectPicPopupWindow彈出窗體的背景
this.setBackgroundDrawable(dw);
//mMenuView添加OnTouchListener監聽判斷獲取觸屏位置如果在選擇框外面則銷毀彈出框
mMenuView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int height = mMenuView.findViewById(R.id.pop_layout).getTop();
int y=(int) event.getY();
if(event.getAction()==MotionEvent.ACTION_UP){
if(y<height){
dismiss();
}
}
return true;
}
});
}
}
第三步:編寫MainActivity類實現測試:
Java代碼
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
public class MainActivity extends Activity {
//自定義的彈出框類
SelectPicPopupWindow menuWindow;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) this.findViewById(R.id.text);
//把文字控制項添加監聽,點擊彈出自定義窗口
tv.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//實例化SelectPicPopupWindow
menuWindow = new SelectPicPopupWindow(MainActivity.this, itemsOnClick);
//顯示窗口
menuWindow.showAtLocation(MainActivity.this.findViewById(R.id.main), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0); //設置layout在PopupWindow中顯示的位置
}
});
}
//為彈出窗口實現監聽類
private OnClickListener itemsOnClick = new OnClickListener(){
public void onClick(View v) {
menuWindow.dismiss();
switch (v.getId()) {
case R.id.btn_take_photo:
break;
case R.id.btn_pick_photo:
break;
default:
break;
}
}
};
}
上述的代碼實現了從底部彈出,也可以根據PopupWindow類設置從左下部彈出。
Android的對話框有兩種:PopupWindow和AlertDialog。它們的不同點在於:
AlertDialog的位置固定,而PopupWindow的位置可以隨意
AlertDialog是非阻塞線程的,而PopupWindow是阻塞線程的
PopupWindow的位置按照有無偏移分,可以分為偏移和無偏移兩種;按照參照物的不同,可以分為相對於某個控制項(Anchor錨)和相對於父控制項。具體如下
showAsDropDown(View anchor):相對某個控制項的位置(正左下方),無偏移
showAsDropDown(View anchor, int xoff, int yoff):相對某個控制項的位置,有偏移
showAtLocation(View parent, int gravity, int x, int y):相對於父控制項的位置(例如正中央Gravity.CENTER,下方Gravity.BOTTOM等),可以設置偏移或無偏移
『肆』 Android4.0底部導航欄最常用是什麼方法實現的
一般都是使用viewpager,下面的是導航欄indicator。點擊導航欄可以切換上面的頁面,當然,滑動上面的頁面下面的導航欄也可以切換。
接著說一下它的實現。類的代碼不復雜,大部分參照了viewpagerindicator中的TabPageIndicator類來實現,不過在這里我繼承的是LinearLayout
『伍』 Android開發,請問這種導航欄怎麼寫
最外層可以用linearlayout,裡面的五個板塊每一個都用一個linearlayout包裹一個imageview和textview,當點擊某一個linear時,改變對應的imageview圖片就可以實現上面的效果了,手機打字的,希望採納啊!
『陸』 android開發時如何去掉底部的導航欄
在一個普通類中(非繼承Activity等),點擊截界面上某一按鈕隱藏底部導航欄(Back、Home、多任務切換),再次點擊讓其出現;
實現:隱藏view.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| Utils.SYSTEM_UI_FLAG_IMMERSIVE);
顯示view.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
而且加了界面touch監聽,在隱藏模式下,單擊屏幕不讓導航欄出現;
『柒』 android底部導航欄怎麼做,
可以使用radiogroup做底部導航
radiogroup的屬性自定義,並設置android:button="@null"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/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">
<!-- 內部組件的排列 -->
<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>
<!-- 設置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>
參考:http://blog.csdn.net/longyi_java/article/details/8485826
『捌』 Android 目前最流行的 底部導航欄 用什麼做的
很多android應用底部都有一個底部導航欄,方便用戶在使用過程中隨意切換。目前常用的做法有三種:一種是使用自定義tabHost,一種是使用activityGroup,一種是結合FrameLayout實現。再做了多款應用後,為了節約開發周期,封裝了一個抽象類,只要三步便可完成底部欄的生成及不同頁面的調用。
public class extends ActivityCollection {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setBottomTabBackground(resId);// 設置底部導航背景圖
@Override
protected boolean isShowWindowFeature() {
return true;//設置是否顯示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(.this,
Activity01.class));
IndicatorInfo indicatorInfo_2 = new IndicatorInfo(R.drawable.baby2,
R.drawable.baby2_s, R.string.baby2, 12, Color.WHITE,
new Intent(.this,
Activity02.class));
IndicatorInfo indicatorInfo_3 = new IndicatorInfo(R.drawable.baby3,
R.drawable.baby3_s, R.string.baby3, 12, Color.WHITE,
new Intent(.this,
Activity03.class));
IndicatorInfo indicatorInfo_4 = new IndicatorInfo(R.drawable.baby4,
R.drawable.baby4_s, R.string.baby4, 12, Color.WHITE,
new Intent(.this,
Activity04.class));
IndicatorInfos.add(indicatorInfo_1);
IndicatorInfos.add(indicatorInfo_2);
IndicatorInfos.add(indicatorInfo_3);
IndicatorInfos.add(indicatorInfo_4);
return IndicatorInfos;
第一步:導入jar包;
第二步:讓自己的homeactivity 繼承ActivityCollection類;
第三步:將自己的圖片資源及跳轉intent放入list中,設置可選項;
雛形就形成啦!
『玖』 新手誠心求助,安卓開發底部的導航欄除了用fragment還有別的選擇嗎
純Activity不是不可以,方案如下:
底部用TabLayout
上方就一個activity layout xml布局
通過切換tab來 控制每個tab對應的 布局塊的 visibility
可以達到不用fragment的效果。
但是:
從軟體工程的角度上講fragment把每個tab邏輯分離,不需要管理其它tab的事情。
耦合度較低。會讓你的代碼可閱讀性更高。代碼是寫給人看的,如果把全部布局,邏輯都揉在一個activity里,估計過不了一周,你可能都看不懂自己的代碼了。
『拾』 Android開發,最下面的導航欄實現切換界面比較好的方法是什麼
可以使用TabHost或者ViewPager都可以達到效果的。你去試試吧