我在XML文件中創建按鈕這樣的:按鈕並繪製左
<Button
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填充和填充左側。 這是我如何活動
Button button1 = new Button(this);
button1.setLayoutParams(new RelativeLayout.LayoutParams(buttonWidth, buttonHeight));
button1.setText(systemTexts.getShowCallButton());
button1.setBackgroundDrawable(new
button1.setTextColor(Color.parseColor(buttonTextColor));
我想你不回答這個問題,OP想要以編程方式進行。 – Joffrey