導航:首頁 > 操作系統 > android旋轉進度

android旋轉進度

發布時間:2022-06-02 15:09:45

安卓怎麼在在對話框中 搞一個進度條

方法/步驟:
單擊按鈕,彈出對話框,對話框中有進度條!
下面 來實現這個功能了

新建一個android工程,定義好xml 只需要一個button就可以了
在MainAtvity中,定義
ProgressDialog m_pDialog;

創建單擊響應事件
在OncliView中可以
m_pDialog = new ProgressDialog(MainActivity.this);

// 設置進度條風格,風格為圓形,旋轉的

m_pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

// 設置ProgressDialog 標題

m_pDialog.setTitle("提示");

// 設置ProgressDialog 提示信息

m_pDialog.setMessage("這是一個圓形進度條對話框");

// 設置ProgressDialog 標題圖標

// 設置ProgressDialog 的進度條是否不明確

m_pDialog.setIndeterminate(false);

// 設置ProgressDialog 是否可以按退回按鍵取消

m_pDialog.setCancelable(true);
m_pDialog.show();
4
完成,單擊按鈕 就可以彈出對話框,(包含進度條~~)

❷ android開發中如何旋轉布局

樓主你好,這個可以通過動畫來達到這個效果的,代碼如下:
只要把您的layout對象傳進去就行了
public void showAnimation(View mView)
{
final float centerX = mView.getWidth() / 2.0f;
final float centerY = mView.getHeight() / 2.0f;
//這個是設置需要旋轉的角度,我設置的是180度
RotateAnimation rotateAnimation = new RotateAnimation(0, 180, centerX,
centerY);
//這個是設置通話時間的
rotateAnimation.setDuration(1000*3);
rotateAnimation.setFillAfter(true);
mView.startAnimation(rotateAnimation);
}

❸ android 類似進度圓環的是怎麼做的

方法:

這是一個自定義Android組件,用於代替標准進度條組件。實現各種進度條樣式,包括圓環,掃描等。
XML:
在你的attr.xml(res/value)中加入以下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

<declare-styleable name="ProgressWheel">
<attr name="text"format="string"/>
<attr name="textColor"format="color"/>
<attr name="textSize"format="dimension"/>
<attr name="barColor"format="color"/>
<attr name="rimColor"format="color"/>
<attr name="rimWidth"format="dimension"/>
<attr name="spinSpeed"format="integer"/>
<attr name="circleColor"format="color"/>
<attr name="radius"format="dimension"/>
<attr name="barWidth"format="dimension"/>
<attr name="barLength"format="dimension"/>
<attr name="delayMillis"format="dimension"/>
<attr name="contourColor"format="color"/>
<attr name="contourSize"format="float"/>
</declare-styleable>

在你的root view 中加入

1

xmlns:ProgressWheel="http://schemas.android.com/apk/res/com.visualdenim.schooltraq"

1

在你的xml合適的地方加入 組件

1
2
3
4
5
6
7
8
9
10
11
12
13

<com.todddavies.components.progressbar.ProgressWheel
android:id="@+id/pw_spinner"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
ProgressWheel:text="Authenticating..."
ProgressWheel:textColor="#222"
ProgressWheel:textSize="14sp"
ProgressWheel:rimColor="#330097D6"
ProgressWheel:barLength="60dp"
ProgressWheel:barColor="#0097D6"
ProgressWheel:barWidth="5dp"
ProgressWheel:rimWidth="2dp"/>

Java:
你需要從layout中獲得進度條,或者初始化

1
2

ProgressWheel pw = newProgressWheel(myContext, myAttributes);
ProgressWheel pw = (ProgressWheel) findViewById(R.id.pw_spinner);

使用.spin() 開始進度條滾動, .stopSpinning 停止進度條滾動
增加進度有點棘手, 你可以調用.incrementProgress(), 但是這樣就超過了360度, 因為一個圓有360度, 你超過360度就會自動重置, 一個百分百自動分配

❹ android屏幕旋轉 如何程序實現屏幕旋轉。 按1個按鈕旋轉90°

屏幕旋轉需要在AndroidManifest.xml的的Activity配置中加入android:screenOrientation=」landscape」屬性。

參數說明:

  1. landscape = 橫向

  2. portrait = 縱向


避免在轉屏時重啟Activity

  1. android中每次屏幕方向切換時都會重啟Activity,所以應該在Activity銷毀前保存當前活動的狀態,在Activity再次 Create的時候載入配置,那樣,進行中的游戲就不會自動重啟了。

  2. 要避免在轉屏時重啟Activity,可以通過在AndroidManifest.xml文件中重新定義方向(給每個Activity加上android:configChanges=」keyboardHidden|orientation」屬性)。

  3. 在需要控制屏幕顯示方向的Activity中重寫onConfigurationChanged(Configuration newConfig)方法。

❺ android 下拉滾動頁面怎麼實現

以下是我自己花功夫編寫了一種非常簡單的下拉刷新實現方案,現在拿出來和大家分享一下。相信在閱讀完本篇文章之後,大家都可以在自己的項目中一分鍾引入下拉刷新功能 最近項目中需要用到ListView下拉刷新的功能,一開始想圖省事,在網上直接找一個現成的,可是嘗試了網上多個版本的下拉刷新之後發現效果都不 怎麼理想。有些是因為功能不完整或有Bug,有些是因為使用起來太復雜,十全十美的還真沒找到。因此我也是放棄了在網上找現成代碼的想法,自己花功夫編寫 了一種非常簡單的下拉刷新實現方案,現在拿出來和大家分享一下。相信在閱讀完本篇文章之後,大家都可以在自己的項目中一分鍾引入下拉刷新功能。 首先講一下實現原理。這里我們將採取的方案是使用組合View的方式,先自定義一個布局繼承自LinearLayout,然後在這個布局中加入下拉 頭和ListView這兩個子元素,並讓這兩個子元素縱向排列。初始化的時候,讓下拉頭向上偏移出屏幕,這樣我們看到的就只有ListView了。然後對 ListView的touch事件進行監聽,如果當前ListView已經滾動到頂部並且手指還在向下拉的話,那就將下拉頭顯示出來,鬆手後進行刷新操 作,並將下拉頭隱藏。原理示意圖如下: 那我們現在就來動手實現一下,新建一個項目起名叫PullToRefreshTest,先在項目中定義一個下拉頭的布局文件pull_to_refresh/apk/res/android" xmlns:tools="schemas/tools" android:id="@+id/pull_to_refresh_head" android:layout_width="fill_parent" android:layout_height="60dip" > <LinearLayout android:layout_width="200dip" android:layout_height="60dip" android:layout_centerInParent="true" android:orientation="horizontal" > <RelativeLayout android:layout_width="0dip" android:layout_height="60dip" android:layout_weight="3" > <ImageView android:id="@+id/arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/arrow" /> <ProgressBar android:id="@+id/progress_bar" android:layout_width="30dip" android:layout_height="30dip" android:layout_centerInParent="true" android:visibility="gone" /> </RelativeLayout> <LinearLayout android:layout_width="0dip" android:layout_height="60dip" android:layout_weight="12" android:orientation="vertical" > <TextView android:id="@+id/description" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_horizontalbottom" android:text="@string/pull_to_refresh" /> <TextView android:id="@+id/updated_at" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_horizontaltop" android:text="@string/updated_at" /> </LinearLayout> </LinearLayout> </RelativeLayout> 在這個布局中,我們包含了一個下拉指示箭頭,一個下拉狀態文字提示,和一個上次更新的時間。當然,還有一個隱藏的旋轉進度條,只有正在刷新的時候我們才會將它顯示出來。 布局中所有引用的字元串我們都放在stringsmit(); new HideHeaderTask()/apk/res/android" xmlns:tools="schemas/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <com.example.pulltorefreshtest.RefreshableView android:id="@+id/refreshable_view" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/list_view" android:layout_width="fill_parent" android:layout_height="fill_parent" > </ListView> </com.example.pulltorefreshtest.RefreshableView> </RelativeLayout> 可以看到,我們在自定義的RefreshableView中加入了一個ListView,這就意味著給這個ListView加入了下拉刷新的功能,就是這么簡單! 然後我們再來看一下程序的主Activity,打開或新建MainActivity,加入如下代碼: 復制代碼 代碼如下: public class MainActivity extends Activity { RefreshableView refreshableView; ListView listView; ArrayAdapter<String> adapter; String[] items = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L" }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); refreshableView = (RefreshableView) findViewById(R.id.refreshable_view); listView = (ListView) findViewById(R.id.list_view); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); listView.setAdapter(adapter); refreshableView.setOnRefreshListener(new PullToRefreshListener() { @Override public void onRefresh() { try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } refreshableView.finishRefreshing(); } }, 0); } } 可 以看到,我們通過調用RefreshableView的setOnRefreshListener方法注冊了一個監聽器,當ListView正在刷新時就 會回調監聽器的onRefresh方法,刷新的具體邏輯就在這里處理。而且這個方法已經自動開啟了線程,可以直接在onRefresh方法中進行耗時操 作,比如向伺服器請求最新數據等,在這里我就簡單讓線程睡眠3秒鍾。另外在onRefresh方法的最後,一定要調用RefreshableView中的 finishRefreshing方法,這個方法是用來通知RefreshableView刷新結束了,不然我們的ListView將一直處於正在刷新的 狀態。 不知道大家有沒有注意到,setOnRefreshListener這個方法其實是有兩個參數的,我們剛剛也是傳入了一個不起眼的 0。那這第二個參數是用來做什麼的呢?由於RefreshableView比較智能,它會自動幫我們記錄上次刷新完成的時間,然後下拉的時候會在下拉頭中 顯示距上次刷新已過了多久。這是一個非常好用的功能,讓我們不用再自己手動去記錄和計算時間了,但是卻存在一個問題。如果當前我們的項目中有三個地方都使 用到了下拉刷新的功能,現在在一處進行了刷新,其它兩處的時間也都會跟著改變!因為刷新完成的時間是記錄在配置文件中的,由於在一處刷新更改了配置文件, 導致在其它兩處讀取到的配置文件時間已經是更改過的了。那解決方案是什麼?就是每個用到下拉刷新的地方,給setOnRefreshListener方法 的第二個參數中傳入不同的id就行了。這樣各處的上次刷新完成時間都是單獨記錄的,相互之間就不會再有影響。 好了,全部的代碼都在這里了,讓我們來運行一下,看看效果吧。 效果看起來還是非常不錯的。我們最後再來總結一下,在項目中引入ListView下拉刷新功能只需三步: 1. 在Activity的布局文件中加入自定義的RefreshableView,並讓ListView包含在其中。 2. 在Activity中調用RefreshableView的setOnRefreshListener方法注冊回調介面。 3. 在onRefresh方法的最後,記得調用RefreshableView的finishRefreshing方法,通知刷新結束。 從此以後,在項目的任何地方,一分鍾引入下拉刷新功能妥妥的。 好了,今天的講解到此結束,有疑問的朋友請在下面留言。 源碼下載,請點擊這里

閱讀全文

與android旋轉進度相關的資料

熱點內容
windows拷貝到linux 瀏覽:751
mdr軟體解壓和別人不一樣 瀏覽:884
單片機串列通信有什麼好處 瀏覽:320
游戲開發程序員書籍 瀏覽:843
pdf中圖片修改 瀏覽:269
匯編編譯後 瀏覽:474
php和java整合 瀏覽:829
js中執行php代碼 瀏覽:442
國產單片機廠商 瀏覽:57
蘋果手機怎麼設置不更新app軟體 瀏覽:284
轉行當程序員如何 瀏覽:493
蘋果id怎麼驗證app 瀏覽:864
查看手機命令 瀏覽:953
抖音反編譯地址 瀏覽:226
如何加密軟體oppoa5 瀏覽:234
java從入門到精通明日科技 瀏覽:96
拆解汽車解壓視頻 瀏覽:598
新版百度雲解壓縮 瀏覽:593
android上下拉刷新 瀏覽:880
centos可執行文件反編譯 瀏覽:839