當前位置:首頁 » 安卓系統 » android50的新控制項

android50的新控制項

發布時間: 2022-04-24 19:13:44

A. 最新的Android控制項有哪些

1.MaterialStepperView
它是用Material Design實現Steppers的。

目前,Stepper只有垂直視圖,但將來會有更多的風格。你可以嘗試一下,如下圖:
你可以自定義normal/active兩個狀態的顏色,完成圖標,開啟動畫並設置動畫時長。可通過Github上的設置項和樣式查閱所有設置項。該庫支持API 17+,詳情請查閱wiki文檔。

2. MultiSnapRecyclerView
這是分屏滾動的Android庫。
MultiSnapRecyclerView為RecyclerView提供了分屏功能。

目前提供的功能有:
start, end和center三個位置的吸附,
snap count 指定要分屏的數量,
支持水平和垂直分屏,
滾動時的回調。
3. Garland View for Android
該庫可實現如下的布局:

GarlandView 外部是一個水平滾動的視圖,視圖內的每一個子視圖可垂直滾動。
你可以在README中找到其他重要信息。還有一個示例App。該庫支持API 19及更高版本。
4. VegaLayoutManager
這是一個自定義的布局管理器——滾動時縮小並淡出頭部。這是受到Dribble項目的啟發。

5. ExpandableLayout
這個庫的名字不言而喻,它是一個基於LinearLayout的可擴展的布局。
README里含有你啟動時需要的所有信息,另外,還有一個示例App可以幫助你快速跳轉到代碼中。
6. SwipeBackLayout
SwipeBackLayout允許你使用手勢返回上一個界面。
你可以設置滑動方向,如從左到右、從右到左、從頂部到底部、從底部到頂部。
你還可以設置是否只能從邊緣滑動。
SwipeBackLayout只能包含一個子布局,例如:
LinearLayout,RelativeLayout,FrameLayout,TableLayout等。
ScrollView,HorizontalScrollView,NestedScrollView等。
RecyclerView,AbsListView(ListView)等子類。
ViewPager,WebView等。
該項目裡面有一個詳細說明的文檔、示例APP和一個APK。

B. Android中有沒有比Spinner控制項更好的選擇

可以使用Button加ListPopupWindow實現和spinner一樣的效果,並且可以監聽到點擊事件(Spinner是不能設置點擊事件的)

布局文件,只有一個button

java"><?xmlversion="1.0"encoding="utf-8"?>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">

<Button
android:id="@+id/button"
android:layout_width="100dp"
android:layout_height="50dp"
/>
</LinearLayout>

代碼


{

privateButtonbutton;
;
privateList<String>strings;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
strings=newArrayList<String>();
strings.add("item1");
strings.add("item2");
strings.add("item3");
button=(Button)findViewById(R.id.button);
popupWindow=newListPopupWindow(this);
popupWindow.setAdapter(newArrayAdapter<String>(this,android.R.layout.simple_list_item_1,strings));
popupWindow.setAnchorView(button);
popupWindow.setWidth(LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(LayoutParams.WRAP_CONTENT);
popupWindow.setModal(true);
popupWindow.setOnItemClickListener(newOnItemClickListener(){

@Override
publicvoidonItemClick(AdapterView<?>parent,Viewview,
intposition,longid){
//TODOAuto-generatedmethodstub
button.setText(strings.get(position));
popupWindow.dismiss();
}
});
button.setOnClickListener(newOnClickListener(){

@Override
publicvoidonClick(Viewv){
popupWindow.show();
}
});
}
}


運行效果

C. android 控制項移動方法

Android控制項位置都是自己設置的。
如果要控制項放到任意位置,建議用RelativeLayout(相對布局)
然後給控制項添加屬性,把控制項放到想要的位置
下面是相對布局中 控制項能用到的屬性。
屬性值為true可false
android:layout_centerHrizontal 水平居中
android:layout_centerVertical 垂直居中
android:layout_centerInparent 相對於父元素完全居中
android:layout_alignParentBottom 貼緊父元素的下邊緣
android:layout_alignParentLeft 貼緊父元素的左邊緣
android:layout_alignParentRight 貼緊父元素的右邊緣
android:layout_alignParentTop 貼緊父元素的上邊緣
屬性值必須為id的引用名
android:layout_below 在某元素的下方
android:layout_above 在某元素的上方
android:layout_toLeftOf 在某元素的左邊
android:layout_toRightOf 在某元素的右邊
android:layout_alignTop 本元素的上邊緣和某元素的上邊緣對齊
android:layout_alignLeft 本元素的左邊緣和某元素的左邊緣對齊
android:layout_alignBottom 本元素的下邊緣和某元素下邊緣對齊
android:layout_alignRight 本元素的右邊緣和某元素右邊緣對齊
屬性值為具體的像素值班,如30dp
android:layout_marginBottom 離某元素底邊緣的距離
android:layout_marginLeft 離某元素左邊緣的的距離
android:layout_marginRight 離某元素的右邊緣的距離
android:layout_marginTop 離某元素上邊緣的距離

D. android 5.0 所有控制項有哪些

分頁控制項 Aspnetpager.dll 這個控制項是控制分頁的,在網上是頂好用的 添加文章控制項 Freetextbook.dll 這個控制項是用來寫文章,可以加粗啊,變字體等等 rss控制項 如題就是用來控制rss編制

E. Android常用控制項

是longclick響應,你在要設置長按響應的view上實現OnLongClickListener介面就行了。至於彈出什麼菜單是你自己決定的,可以是alterdialog也可以是別的。

F. android開發,程序中如何修改控制項的相對布局

RelativeLayout layout =(RelativeLayout) findViewById(R.id.layout);
Button but = new Button(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(50,50);
lp.addRule(RelativeLayout.ALIGN_TOP,R.id.button);
lp.addRule(RelativeLayout.ALIGN_RIGHT,R.id.button);
layout.addView(but, lp);

關鍵是 addRule 方法 看代碼很顯然,是指定對齊button的頂端和右端。

另一種思路是,先在xml里配置好兩個button。不過先把上面的button的visibility 設置為gone,用到的時候在java代碼里設置為visible。

G. 求解:android中如何實現動態插入控制項

直接給你上代碼吧,寫了我半個小時,經過了我的測試了的~

運行下就能看到結果了~關鍵的remove的時候有給你寫注釋~

布局的layout文件內容:
----------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linearlayout">

<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<Button android:layout_height="wrap_content" android:id="@+id/add"
android:text="Add" android:layout_width="100px"></Button>
<Button android:layout_height="wrap_content"
android:layout_width="100px" android:text="Remove" android:id="@+id/remove"></Button>
</LinearLayout>
<TextView android:id="@+id/TextView01" android:text="This is textView."
android:layout_width="fill_parent" android:gravity="center"
android:layout_height="50px"></TextView>

</LinearLayout>
----------------------------------------------------------------------------------

對應Activity的內容:
----------------------------------------------------------------------------------
package com.foxconn.dialog;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;

public class DialogTest extends Activity implements OnClickListener {

private Button add_btn, remove_btn;
private LinearLayout linearLayout;
private int index = 0;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViews();
register();
}

private void register() {
add_btn.setOnClickListener(this);
remove_btn.setOnClickListener(this);
}

private void findViews() {
add_btn = (Button) findViewById(R.id.add);
remove_btn = (Button) findViewById(R.id.remove);
linearLayout = (LinearLayout) findViewById(R.id.linearlayout);
}

protected View createView() {
Button btn = new Button(this);
btn.setId(index++);
btn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
btn.setText("aaaaaa" + index);
return btn;
}

private void removeView() {
//獲取linearlayout子view的個數
int count = linearLayout.getChildCount();
//研究整個LAYOUT布局,第0位的是含add和remove兩個button的layout
//第count-1個是那個文字被置中的textview
//因此,在remove的時候,只能操作的是0<location<count-1這個范圍的
//在執行每次remove時,我們從count-2的位置即textview上面的那個控制項開始刪除~
if (count - 2 > 0) {
//count-2>0用來判斷當前linearlayout子view數多於2個,即還有我們點add增加的button
linearLayout.removeViewAt(count - 2);
}
}

public void onClick(View v) {
switch (v.getId()) {
case R.id.add:
linearLayout.addView(createView(), 1);
break;
case R.id.remove:
removeView();
break;
default:
break;
}
}
}
----------------------------------------------------------------------------------

H. 關於android控制項的應用!求解 高分奉上!

/*Button bn1 = (Button)findViewById(R.id.bn1);
Button bn2 = (Button)findViewById(R.id.bn2);
bn1.setText("");
bn2.setText("");
bn1.setBackgroundColor(Color.RED);
bn2.setBackgroundResource(R.drawable.exit1);
建立了兩個button bn1和 R.id.bn1關聯
bn2同
關聯,簡單點說就是 當有按下這個button,系統發出的消息中的標示是R.id.bn1

Resources re= getResources();
Drawable dr = re.getDrawable(R.drawable.icon);
bn1.setBackgroundDrawable(dr);

這段功能是獲取 標記為R.drawable.icon的一張圖片,並把bn1的背景設置為這張圖片

ImageView im = (ImageView)findViewById(R.id.ImageView01);
ImageButton imb = (ImageButton)findViewById(R.id.ImageButton01);

im.setImageResource(R.drawable.exit1);
imb.setImageDrawable(dr);
讀取一張圖im,為R.drawable.exit1,
生成一個Imagebutton 關聯為R.id.ImageButton01,同時這個button的圖片是剛讀取的圖im.

final Animation ani = AnimationUtils.loadAnimation(this, R.anim.anim);
讀取一個動畫,標記為R.anim.anim(定義在某個xml文件內)

bn2.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
v.startAnimation(ani);
}
});

為bn2建立一個事件監聽器,點擊後 就顯示剛才生成的動畫

RadioButton rb = (RadioButton)findViewById(R.id.RadioButton01);
rb.setBackgroundColor(Color.BLACK);
rb.setBackgroundResource(R.drawable.icon);
RadioGroup rg = (RadioGroup)findViewById(R.id.RadioGroup01);
rg.setBackgroundColor(Color.BLACK);

也是生成一種button,具體lz看生成的界面就明白了,語法和剛才的代碼差不多

ArrayAdapter<String> aa = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,new String[]{"hello","world","android","sun"});
Spinner sp = (Spinner)findViewById(R.id.Spinner01);
sp.setAdapter(aa);

建立一個字元串管理器,再建立一個Spinner對象叫sp,關聯R.id.Spinner01
把剛才的配置器配給sp
這里spinner和adapter具體干什麼的我身邊沒doc,不過你運行後的圖形界面應該一眼就知道了,這里只是給你講下語法

final ProgressBar pb=(ProgressBar)findViewById(R.id.ProgressBar01);
pb.setMax(100);
pb.setProgress(50);
pb.setSecondaryProgress(70);
Button bnp = (Button)findViewById(R.id.Bup);
bnp.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
pb.incrementProgressBy(1);
pb.incrementSecondaryProgressBy(-1);
}
});

}}

生成一個進度條和一個按鈕,進度條有2條一個主條一個附條
按以下按鈕主條+1附條-1

還有不會的hi我~

I. android界面開發常用的控制項有哪些

控制項開發大致分為兩種: 1.組合式開發。將幾個android現成的控制項,如ImageView,Button等糅合在一起。 2.單獨開發。一般繼承View,然後重寫其onDraw和onMeasure等方法。若是ViewGroup,則還需重寫measureChildren等。 上面說的是2D控制項。3D則需繼承SurfaceView。

J. Android基礎技術及基本控制項

安卓基礎技術主要是講解一些安卓系統運行的原理,還有一些基本的組件,所有的安卓應用程序都是在這些組件構成的,基本控制項主要就是一些類似按鈕,進度條,滾動條這些圖形界面組件,還有一些是用戶自定義的組件。

熱點內容
所有編程語言 發布:2024-05-19 21:33:55 瀏覽:664
c語言1到10的階乘的和 發布:2024-05-19 21:32:25 瀏覽:627
php匹配標點符號 發布:2024-05-19 21:14:49 瀏覽:752
可以拍照輸入的c語言編譯器 發布:2024-05-19 21:09:47 瀏覽:181
解壓升降機 發布:2024-05-19 20:51:11 瀏覽:967
請稍作停留密碼是什麼意思 發布:2024-05-19 20:37:12 瀏覽:244
linux結束符 發布:2024-05-19 20:33:05 瀏覽:817
招標伺服器雲 發布:2024-05-19 20:04:19 瀏覽:584
搭建小米雲伺服器 發布:2024-05-19 19:43:17 瀏覽:131
蘋果手機備忘錄怎麼加密 發布:2024-05-19 18:57:57 瀏覽:16