Android:控件

TextView

<TextView
        android:id="@+id/tv_one"   			# findViewById(R.id.tv_one);
        android:layout_width="200dp"  		# 宽度,单位dp
        android:layout_height="200dp"  		# 高度
        android:text="@string/one_text" 	# 文本内容
        android:textColor="#FFFF0000"  		# 透明度+RGB
        android:textStyle="italic"    		# normal, bold, italic
        android:textSize="30sp"      		# 字体大小,单位sp
        android:background="#FFFFFF00"  	# 颜色、图片
        android:gravity="center"			# 文字、图片的位置
        
        android:shadowColor="@color/black"	# 阴影颜色
        android:shadowRadius="3.0"			# 阴影模糊度
        android:shadowDx="10.0"				# 阴影x轴偏移量
        android:shadowDy="10.0"				# 阴影y轴偏移量
        
        android:singleLine="true"			# 单行显示
        android:ellipsize="marquee"			# 跑马灯显示
        android:marqueeRepeatLimit="marquee_forever"
        android:focusable="true"			# 获取焦点
        android:focusableInTouchMode="true"	# 触摸
        android:clickable="true"			# 允许点击
        />
public class MyTextView extends TextView {
    public MyTextView(Context context) {
        super(context);
    }

    public MyTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean isFocused() {
        return true;
    }
}
<TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <requestFocus/>
</TextView>

Button

在这里插入图片描述

@RemoteView
public class Button extends TextView
#设置成Bridge
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge">

#设置选择器
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_baseline_account_balance_24" android:state_pressed="true"/>
    <item android:drawable="@drawable/ic_baseline_accessibility_new_24"/>
</selector>

#设置背景、背景色、前景色
<Button
        android:id="@+id/button_tx"
        android:text="@string/app_name"
        android:background="@drawable/button_select"
        android:backgroundTint="#ffff0000"
        android:foreground="@color/black"
        android:layout_width="200dp"
        android:layout_height="100dp"/>
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 获取Button对象
        Button btn = findViewById(R.id.button_tx);

        // 设置点击事件
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        // 设置长按事件
        btn.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return false;
            }
        });

        // 设置触摸事件
        btn.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return false;
            }
        });
    }
}

EditText

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

ImageView

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

ProgressBar

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Notification

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Toolbar

在这里插入图片描述

<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

AlertDialog

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

PopupWindow

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值