如何在android中绘制一个矩形,并在其中放入一些文本,然后将其放置?
嗨,我有一个活动,在活动中我有一些按钮和文本视图,我想画一个里面有文本的矩形。我在网上看到了一些例子,但都说要创建我的on视图,覆盖onDraw并将此视图设置为我的布局,但我已经有了我的布局如何在android中绘制一个矩形,并在其中放入一些文本,然后将其放置?,android,draw,Android,Draw,嗨,我有一个活动,在活动中我有一些按钮和文本视图,我想画一个里面有文本的矩形。我在网上看到了一些例子,但都说要创建我的on视图,覆盖onDraw并将此视图设置为我的布局,但我已经有了我的布局 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView baramzona = (
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView baramzona = (TextView) findViewById(R.id.TextView01);
baramzona.setText(R.string.baram_zona_textview);
final Button pocniparking = (Button) findViewById(R.id.ButtonStart);
final TextView momentalnazona = (TextView) findViewById(R.id.TextView02);
//momentalnazona.setText("Моментално се наоѓате во зоната");
pocniparking.setText(R.string.btn_Start_Parking);
pocniparking.setEnabled(false);
}
}
有什么想法吗?这是一种变通方法,但它符合我的目的。基本上,您可以将TextView放在表格中,为大纲设置表格背景,并为大纲的大小设置边距。希望能有帮助
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#55771B">
<TextView android:text="@+id/TextView01"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3px"
android:layout_marginBottom="3px"
android:layout_marginRight="3px"
android:layout_marginTop="3px"
android:background="#010101"/>
</TableLayout>
创建自己的视图听起来有些过分。我会研究你是否可以在文本视图上设置背景或边框。找到这个,我将尝试一下