这个静态按钮可以用java代码完成吗?
这是按钮的外观: 按钮是用静态xml完成的 最后,我要回答我的问题:这个静态按钮可以用java代码完成吗?,java,android,button,Java,Android,Button,这是按钮的外观: 按钮是用静态xml完成的 最后,我要回答我的问题: android:drawableTop="@drawable/randomImage" android:gravity="center_horizontal|bottom" 通讯员: android:gravity="center_horizontal|bottom" android:drawableTop="@drawable/randomImage" 及 通讯员: android:gravity="center_h
android:drawableTop="@drawable/randomImage"
android:gravity="center_horizontal|bottom"
通讯员:
android:gravity="center_horizontal|bottom"
android:drawableTop="@drawable/randomImage"
及
通讯员:
android:gravity="center_horizontal|bottom"
android:drawableTop="@drawable/randomImage"
如何设置重心,使其同时处于
水平中心|底部
。我看到有一种方法Button.setGravity(Gravity.CENTER\u HORIZONTAL)
和Button.setGravity(Gravity.BOTTOM)
,但如何应用这两种方法。还有怎么做呢?android:drawableTop=“@drawable/randomage”
我应该附上一张按钮显示方式的图片。关于android:drawableTop=“@drawable/randomage”
?实际上你是不对的!我改变了你的答案setGravity(重力。重心水平|重力。底部)我不知道,在你给了我一个错误的答案之后,你为什么投反对票?!??
setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom);
Button mButton_dial = null;
mButton_dial = new Button(this);
mButton_dial.setText("Dial!");
mLinearLayout_no_button = new LinearLayout(this);
mLinearLayout_no_button.addView(mButton_dial);
mButton_dial.setGravity(20);
mButton_dial.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});