我正在開發一個多設備android應用程序。所有工作都很好,但有2件事。進度對話框和在android中顯示非常小的祝詞,但在S2中完美。任何人都可以請建議任何解決方法,以增加麪包的大小和進步和責任。我已經在清單中提到了屏幕支持,但沒有用。開發自定義progressdialog android
0
A
回答
1
您可以創建自定義的烤麪包,您可以在其中定義自己的佈局。結賬下面的代碼。
命名爲「custom_toast.xml」
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00AAE9"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<ImageView
android:id="@+id/toastImage"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
android:src="@drawable/ic_warning" />
<TextView
android:id="@+id/toastText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:textColor="#FFFFFF"
android:textSize="7pt"
android:textStyle="italic" />
</LinearLayout>
</LinearLayout>
你的活動類
package com.javatechig.droid.ui;
import android.os.Bundle;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button toastButton = (Button) this.findViewById(R.id.toastButton);
toastButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//create the toast object, set display duration,
Toast.makeText(getApplicationContext(), "This is a plain toast.",
Toast.LENGTH_SHORT).show();
}
});
Button customToastButton = (Button) this.findViewById(R.id.customToastButton);
customToastButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//get the LayoutInflater and inflate the custom_toast layout
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup)
findViewById(R.id.toast_layout_root));
//get the TextView from the custom_toast layout
TextView text = (TextView) layout.findViewById(R.id.toastText);
text.setText("This is my custom toast");
//create the toast object, set display duration,
//set the view as layout that's inflated above and then call show()
Toast t = new Toast(getApplicationContext());
t.setDuration(Toast.LENGTH_LONG);
t.setView(layout);
t.show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
輸出下面
1
您可以設置查看任何類型的對話框的XML佈局或烤麪包,以定製外觀。吐司樣本在山姆下面提到e適用於警報或進度對話框。
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate
(R.layout.custom_toast,(ViewGroup) findViewById(R.id.toast_layout_root));
TextView text = (TextView) layout.findViewById(R.id.text); text.setText("This is a custom toast");
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout); toast.show();
相關問題
- 1. 使用自定義ProgressDialog android
- 2. 如何自定義Android ProgressDialog?
- 3. Android自定義ProgressDialog動畫
- 4. 自定義ProgressDialog
- 5. Android調用自定義ProgressDialog - 如何?
- 6. Android自定義ProgressDialog與消息
- 7. 如何在android中自定義ProgressDialog?
- 8. 自定義可繪製ProgressBar/ProgressDialog
- 9. 如何創建自定義progressDialog
- 10. ProgressDialog具有自定義圖像
- 11. 如何製作自定義ProgressDialog Android? (未清理標準ProgressDialog的尺寸)
- 12. OpenSSL自定義開發
- 13. Sitefinity和自定義開發
- 14. iPhone開發 - 自定義Cel
- 15. 自定義ProgressDialog擴展對話框或ProgressDialog?
- 16. ProgressDialog的自定義顏色和背景
- 17. 使用動畫製作自定義progressdialog
- 18. 在android中自定義progressdialog動態創建
- 19. 在任何類中動態顯示Android自定義ProgressBar或ProgressDialog
- 20. 從Android中的ProgressDialog中的新線程訪問自定義類
- 21. 我們可以在android中自定義progressdialog嗎?
- 22. 開發自定義鎖定屏幕
- 23. Titanium開發者,Android模擬器 - 傳遞自定義參數
- 24. 自定義可更新列表視圖 - Android開發
- 25. 我可以在android中開發自定義相機嗎?
- 26. Android:在自定義開關佈局上發生錯誤
- 27. Android開發 - 自定義按鈕外觀/行爲
- 28. Android開發:如何製作自定義狀態欄通知?
- 29. 開發Android Auto自定義應用程序
- 30. 如何在自定義Android鍵盤中開發NEXT按鈕
感謝您的回覆,我們可以對進度條也做同樣的事情嗎? – bharath 2013-05-02 09:33:58