您好,我有一个 Activity ,在 Activity 中我有一些按钮和 TextView ,我想绘制一个包含文本的矩形。我在网上看到了一些示例,但都说要创建我的 on view ,覆盖 onDraw 并将此 View 设置为我的布局,但我已经有了我的布局。
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>
关于android - 我如何在android中绘制一个矩形并在其中放置一些文本然后放置它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3325883/