zoukankan      html  css  js  c++  java
  • Android 自定义吐司通知

        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            button = (Button) findViewById(R.id.button);
    
            button.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
    
                    Toast toast = new Toast(MainActivity.this);
    
                    View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.toast, null);
    
                    ImageView imageView = (ImageView) view.findViewById(R.id.image);
                    imageView.setImageResource(R.drawable.a1);
    
                    // 居中显示
                    toast.setGravity(Gravity.CENTER, 0, 0);
    
                    // 加载自定义布局
                    toast.setView(view);
                    toast.show();
                }
            });
        }
    <?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="horizontal" >
    
        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_marginRight="10dp" />
    
        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="自定义吐司通知"
            android:textColor="#000000" />
    
    </LinearLayout>

    image

  • 相关阅读:
    PHP 数据库连接
    php函数
    php数组基础
    Jquery元素追加和删除
    jquery获取父,同,子级元素
    深入理解css中position属性及z-index属性
    php运算符
    MySQL主键与索引的区别和联系
    php 常量
    20150408--Sphinx+邮件激活-02
  • 原文地址:https://www.cnblogs.com/zhangxuechao/p/11800465.html
Copyright © 2011-2022 走看看