android drawable button,android – Button和drawable left

我在xml文件中创建按钮,如下所示:

android:id="@+id/call_button"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_marginTop="30dp"

android:background="@drawable/button"

android:layout_weight="40"

android:drawableLeft="@drawable/symbol_phone"

android:paddingLeft="20dp"

android:drawablePadding="-25dp"

android:text="Call"

android:textColor="@color/white"

/>

我想知道如何在活动中做drawableLeft.我知道这很愚蠢,但我需要在活动中这样做,因为我在那里创建了按钮.我如何在活动中的xml文件中执行相同的操作?我需要添加drawableLeft和drawable padding以及padding left.

这就是我在活动中创建按钮的方式

Button button1 = new Button(this);

button1.setLayoutParams(new RelativeLayout.LayoutParams(buttonWidth,buttonHeight));

button1.setText(systemTexts.getShowCallButton());

button1.setBackgroundDrawable(new

button1.setTextColor(Color.parseColor(buttonTextColor));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值