<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/waitbar"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/control_waitbar_wait"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
/>
<TextView
android:id="@+id/control_waitbar_tv_waitmsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/white"
android:text=""
/>
</LinearLayout>
--
package kd.scan;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.InputType;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class Control_Waitbar extends LinearLayout{
private TextView control_waitbar_tv_waitmsg;
public Control_Waitbar(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
try{
LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.control_waitbar, this);
control_waitbar_tv_waitmsg=(TextView)findViewById(R.id.control_waitbar_tv_waitmsg);
}catch(Exception e){
Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
e.getCause();
}
}
//显示或者隐藏进度条
public void setText(String msg){
control_waitbar_tv_waitmsg.setText(msg);
}
}
--drawable目录下 waitbar
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#000"
android:endColor="#fff"
android:angle="45" />
</shape>