标签:xtend data- sch ttext protect htm class main 布局
<?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:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#448899" android:text="你好" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> </LinearLayout>
package com.example.checkboxtext;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void toastshow(View view){
// Toast toast = Toast.makeText(MainActivity.this, "toastshow", 0);
// toast.setText("你好");
// toast.setGravity(Gravity.TOP|Gravity.LEFT, 30, 200);//显示在距离顶部200,距离left30的位置
// toast.show();
Toast toast = new Toast(MainActivity.this);
View view2 = View.inflate(MainActivity.this, R.layout.toast, null);//把一个布局转化成一个view对象
toast.setView(view2);
toast.setDuration(0);//定义时间长短0(短)或1(长)
toast.setGravity(Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
}
标签:xtend data- sch ttext protect htm class main 布局
原文地址:http://www.cnblogs.com/jzdwajue/p/6925871.html