我正在开发一个多设备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