當前位置:首頁 » 安卓系統 » android左側欄

android左側欄

發布時間: 2023-08-06 05:01:32

① Android Studio左側Project側邊欄如何設置默認顯示的是Project

很多Android Stuio初學者可能會一不小心把左邊的Project欄給關了,結果發現找很久也沒找到怎麼再打

② android 怎麼實現左側推出導航菜單

Android左側推出導航菜單可以讓Activity繼承PopupWindow類來實現的彈出窗體,布局可以根據自己定義設計。彈出效果主要使用了translate和alpha樣式實現。具體的做法是下列代碼:

java">第一步:設計彈出窗口xml:

Xml代碼
<?xmlversion="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代碼
importandroid.app.Activity;
importandroid.content.Context;
importandroid.graphics.drawable.ColorDrawable;
importandroid.view.LayoutInflater;
importandroid.view.MotionEvent;
importandroid.view.View;
importandroid.view.View.OnClickListener;
importandroid.view.View.OnTouchListener;
importandroid.view.ViewGroup.LayoutParams;
importandroid.widget.Button;
importandroid.widget.PopupWindow;

{


privateButtonbtn_take_photo,btn_pick_photo,btn_cancel;
privateViewmMenuView;

publicSelectPicPopupWindow(Activitycontext,OnClickListeneritemsOnClick){
super(context);
LayoutInflaterinflater=(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(newOnClickListener(){

publicvoidonClick(Viewv){
//銷毀彈出框
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顏色為半透明
ColorDrawabledw=newColorDrawable(0xb0000000);
//設置SelectPicPopupWindow彈出窗體的背景
this.setBackgroundDrawable(dw);
//mMenuView添加OnTouchListener監聽判斷獲取觸屏位置如果在選擇框外面則銷毀彈出框
mMenuView.setOnTouchListener(newOnTouchListener(){

publicbooleanonTouch(Viewv,MotionEventevent){

intheight=mMenuView.findViewById(R.id.pop_layout).getTop();
inty=(int)event.getY();
if(event.getAction()==MotionEvent.ACTION_UP){
if(y<height){
dismiss();
}
}
returntrue;
}
});

}

}

第三步:編寫MainActivity類實現測試:

Java代碼
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.view.Gravity;
importandroid.view.View;
importandroid.view.View.OnClickListener;
importandroid.widget.TextView;

{

//自定義的彈出框類
;

@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextViewtv=(TextView)this.findViewById(R.id.text);
//把文字控制項添加監聽,點擊彈出自定義窗口
tv.setOnClickListener(newOnClickListener(){
publicvoidonClick(Viewv){
//實例化SelectPicPopupWindow
menuWindow=newSelectPicPopupWindow(MainActivity.this,itemsOnClick);
//顯示窗口
menuWindow.showAtLocation(MainActivity.this.findViewById(R.id.main),Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL,0,0);//設置layout在PopupWindow中顯示的位置
}
});
}

//為彈出窗口實現監聽類
=newOnClickListener(){

publicvoidonClick(Viewv){
menuWindow.dismiss();
switch(v.getId()){
caseR.id.btn_take_photo:
break;
caseR.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等),可以設置偏移或無偏移

③ android studio 左右兩邊導航欄怎麼點出來

打開AndroidStudio工具,點擊「設置」按鈕,如圖:

左側導航欄,選擇「Editor」,如圖:

右面往下拉滑鼠,直到最後,找到「show quick doc……」如圖:

打上對勾,選擇apply ,點擊OK,如圖:

進入代碼,將滑鼠移上去,就會看到懸浮提示窗口,如圖:

④ 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等),可以設置偏移或無偏移

⑤ Android系統屏幕左邊有個小的拉出菜單要怎麼去掉

1、點擊圖標,看看是哪個軟體的快捷組件。

2、打開軟體的設置,取消桌面或其它界面顯示就OK。

另外,也可以通過許可權設置,禁止軟體顯示通知等等,禁止這一類的組件和任務欄顯示。

比如使用LBE安全大師,打開安全和隱私,打開許可權設置,禁止廣告和任務欄顯示就可以禁止出現。

⑥ 安卓adt左側文件欄怎麼調

進入工作平台或者點擊dxp。
打開altiumdesigner進入工作平台,點擊右下方的system,出現菜單列表,勾選你需要顯示的左側菜單,我們以libary為例,勾選後就立即顯示出來了。還有一個辦法,點擊dxp,在dxp菜單下點擊preferences,進入屬性窗口,點擊system--genaral,勾選uselocalizedresours,出現彈窗,點擊OK即可。
ADT(Android開發工具)是Eclipse的插件,它提供了一套與EclipseIDE集成的工具。它可以讓您訪問許多功能,幫助您快速開發Android應用程序。ADT提供對許多命令行SDK工具的GUI訪問以及用於快速原型設計,設計和構建應用程序用戶界面的UI設計工具。

熱點內容
促銷演算法模型 發布:2025-03-16 16:56:55 瀏覽:92
線程非同步java 發布:2025-03-16 16:51:52 瀏覽:258
軟體編程有哪些 發布:2025-03-16 16:46:07 瀏覽:479
最近上傳91 發布:2025-03-16 16:46:03 瀏覽:703
珍珠台編程 發布:2025-03-16 16:40:25 瀏覽:898
伺服器如何連接寬頻 發布:2025-03-16 16:31:19 瀏覽:656
電腦硬體消息查詢腳本 發布:2025-03-16 16:22:39 瀏覽:866
寶馬五系降價取消了哪些配置 發布:2025-03-16 16:09:41 瀏覽:240
學班java 發布:2025-03-16 16:09:00 瀏覽:599
切金磚解壓 發布:2025-03-16 16:08:45 瀏覽:774